Thursday, January 5, 2012

C/C++ Fundamental data type, int

C/C++ Fundamental data type, int

In C/C++, variable of int can be defined and initiated using the form:
int i1 = 10;
int i2(20);


In Windows 8(Developer Preview), it's size id 4 byte.

Example:
C/C++ Fundamental data type, int
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int i1 = 10;
int i2(20);

cout << "size of i1(int): " << sizeof(i1) << endl;
cout << "i1 = " << i1 << endl;
cout << "size of i2(int): " << sizeof(i2) << endl;
cout << "i2 = " << i2 << endl;
system("PAUSE");
return 0;
}

No comments:

Post a Comment