Cardinal in c/c++

Status
Niet open voor verdere reacties.
http://www.kissysoftware.com/functions/integers.html

unsigned int, Cardinal, and UINT

The unsigned int, its Borland redefined Cardinal, and the Win32 UINT, data types are used to identify a 32-bit positive integer variable whose value would range from 0 to 2147484647.

C++ Builder provides an effective checking process when you use the Cardinal or the USHORT, which improves the code. For example, if the user (or the program) is supposed to provide a positive number, such as the count of students in a classroom, but provides anything else than a positive integer, the compiler would reset the value of the variable to 1; consequently, no error (called exception) would be raised. Therefore, when writing a program, it is safer to declare a positive integer as Cardinal or USHORT.

//---------------------------------------------------------------------------

#include <vcl.h>
#include <iostream.h>
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
unsigned int Books;
Cardinal NbrOfToes;
USHORT NbrOfPeople;

cout << "Estimate the number of books you have: ";
cin >> Books; cout << "How many toes does a porc have? ";
cin >> NbrOfToes;
cout << "Enter the number of people who live with you: ";
cin >> NbrOfPeople;

cout << "\nYou have a collection of " << Books << " books";
cout << "\nFrom the information you supplied, a porc has "
<< NbrOfToes << " toes.";
cout << "\nYou live in a house of " << NbrOfPeople << " people.";

cout << "\n\nPress any key to continue...";
getchar();
return 0;
}
//---------------------------------------------------------------------------
 
ik versta onder een integer een ding als -1 -2 -3 0 1 2 3 en onder een cardinal 0 1 2 3 3 4 6 5 enz wordt dit verschil gemaakt in c/c++

Groeten.
 
oké bedankt denk het al te zien.

In mijn vorige taal (modula2) maakte men expliciet onderscheid tussen gehele en gehele positieve omdat ik dat niet onmiddellijk terug vond in c/c++ dacht ik bestaat dit hier dan niet?

Nu in het algemeen zal men dus hier dat onderscheid niet maken maar later in het specifieke weer wel, ga je linkje een bestuderen Bedankt!!

Groeten.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan