Home arrow C and C+ arrow C and C++ Data Types
C and C++ Data Types PDF
Sunday, 19 April 2009
Here is a table with predefined C and C++ Data Types

Data typeSize in BytesSize in Bits
Interval
 char1
8
 from -128 to 127
 unsigned char
1
8
 from 0 to 255
 signed char
1 8from -128 to 127
 enum4
32
 
 short2 16 from -32768 to 32767
 int4
32
 from -2147483648 to 2147483647
 unsigned4
32
 from 0 to 4294967295
 long4
 32 from -2147483648 to 2147483647
 unsigned long
4
32
 from 0 to 4294967295
 float4
32
 
 double8
64
 
 long double
1296
 
 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
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. int a;
  8. char b;
  9. unsigned char c;
  10. signed char d;
  11. short e;
  12. unsigned f;
  13. long g;
  14. unsigned long h;
  15. float i;
  16. double j;
  17. long double k;
  18.  
  19. int *l;
  20.  
  21. cout << "int - " << sizeof(a) << endl;
  22. cout << "char - " << sizeof(b) << endl;
  23. cout << "unsigned char - " << sizeof(c) << endl;
  24. cout << "signed char - " << sizeof(d) << endl;
  25. cout << "short - " << sizeof(e) << endl;
  26. cout << "unsigned - " << sizeof(f) << endl;
  27. cout << "long - " << sizeof(g) << endl;
  28. cout << "unsigned long - " << sizeof(h) << endl;
  29.  
  30. cout << "float - " << sizeof(i) << endl;
  31. cout << "double - " << sizeof(j) << endl;
  32. cout << "long double - " << sizeof(k) << endl;
  33.  
  34. cout << "type * - " << sizeof(l) << endl;
  35. }

 





Last Updated ( Wednesday, 22 April 2009 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?