Here is a table with predefined C and C++ Data Types
| Data type | Size in Bytes | Size in Bits
| Interval
| | char | 1
| 8
| from -128 to 127
| unsigned char
| 1
| 8
| from 0 to 255
| signed char
| 1 | 8 | from -128 to 127
| | enum | 4
| 32
| | | short | 2 | 16 | from -32768 to 32767
| | int | 4
| 32
| from -2147483648 to 2147483647 | | unsigned | 4
| 32
| from 0 to 4294967295 | | long | 4
| 32 | from -2147483648 to 2147483647
| unsigned long
| 4
| 32
| from 0 to 4294967295 | | float | 4
| 32
| | | double | 8
| 64
| | long double
| 12 | 96
| | tip *
| 4
| 32
| |
The table show C / C++ data types for a UNIX / Linux 32 bit machine. On different platform the size of data types might differ. You can check your data type size for your platform with a C++ program like the following one:
data_types.cc #include <iostream> using namespace std; int main(void) { int a; char b; unsigned char c; signed char d; short e; unsigned f; long g; unsigned long h; float i; double j; long double k; int *l; cout << "int - " << sizeof(a ) << endl; cout << "char - " << sizeof(b ) << endl; cout << "unsigned char - " << sizeof(c ) << endl; cout << "signed char - " << sizeof(d ) << endl; cout << "short - " << sizeof(e ) << endl; cout << "unsigned - " << sizeof(f ) << endl; cout << "long - " << sizeof(g ) << endl; cout << "unsigned long - " << sizeof(h ) << endl; cout << "float - " << sizeof(i ) << endl; cout << "double - " << sizeof(j ) << endl; cout << "long double - " << sizeof(k ) << endl; cout << "type * - " << sizeof(l ) << endl; }
|