Home arrow C and C+ arrow C and C++ Data Types
C and C++ Data Types PDF
Wednesday, 08 February 2012
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.c
#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;
}

Last Updated ( Wednesday, 08 February 2012 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?