1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> using namespace std; int main() { cout<< "The size of an int is:\t\t" << sizeof ( int ) << "bytes..\n" ; cout<< "The size of a short int is:\t" << sizeof ( short ) << "bytes..\n" ; cout<< "The size of a long int is:\t" << sizeof ( long ) << "bytes..\n" ; cout<< "The size of a char is:\t\t" << sizeof ( char ) << "bytes..\n" ; cout<< "The size of a float is:\t\t" << sizeof ( float ) << "bytes..\n" ; cout<< "The size of a double is:\t" << sizeof ( double ) << "bytes..\n" ; cout<< "The size of a bool is:\t\t" << sizeof ( bool ) << "bytes..\n" ; return 0; } |
sizeof(변수);
사용하는 개체의 크기를 알려준다.
형태 | 크기 |
값 |
bool | 1바이트 | 참/거짓 |
unsigned short int |
2바이트 | 0~65,535 |
short int |
2바이트 | -32,435~32,767 |
unsigned long int |
4바이트 | 0~4,294,967,295 |
long int |
4바이트 | -2,147,483,648~2,147,483,647 |
int(16비트) | 2바이트 | -32,768~32,767 |
int(32비트) | 4바이트 | -2,147,483,648~2,147,483,647 |
unsigned int(16비트) |
2바이트 | 0~65,535 |
unsigned int(32비트) |
4바이트 | 0~4,294,967,295 |
char | 1바이트 | 256 문자값들 |
float | 4바이트 | 1.2e-38~3.4e38 |
double | 8바이트 | 2.2e-308~1.8e308 |
'프로그래밍 > C++' 카테고리의 다른 글
특수 출력 문자(이스케이프 문자) (0) | 2011.08.19 |
---|---|
예약어 typedef (0) | 2011.08.19 |
C++ 프로그램 개발의 단계 (0) | 2011.08.18 |
C++ 객체지향 프로그래밍 (0) | 2011.08.18 |
회원 관리 / 까페(마일리지) (0) | 2011.06.21 |