삽이 부서질 때까지 삽질

[c++] 자료형 본문

c cpp

[c++] 자료형

xinfo 2016. 10. 19. 14:07

cpp에서 자료형에 대해서 알아봅시다.


카테고리 

타입 

바이트 

최소 

최대 

 Integer

int 

-2,147,483,648 

2,147,483,647

unsigned int

4,294,967,295

char 

-128 

127 

unsigned  char

255 

short 

-32,768 

23,767 

unsigned short 

65,535 

long 

-2,147,483,648 

2,147,483,647

unsigned long

 263-1

long long

-263-1

 263-1

usigned long long

8

0

 264-1

 Real

Numbers

float 

3.4 e 38 

34.e - 38 

double 

8

1.7 e308

1.7 e - 308 

long dobule

12 

 

 

 Boolen

Numbers

bool

 1

 false (0)

true 

(1 or 0이아닌수) 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
 
int main() {
    cout << "sizeof(char) is " << sizeof(char<< " bytes " << endl;
    cout << "sizeof(short) is " << sizeof(short<< " bytes " << endl;
    cout << "sizeof(int) is " << sizeof(int<< " bytes " << endl;
    cout << "sizeof(long) is " << sizeof(long<< " bytes " << endl;
    cout << "sizeof(long long) is " << sizeof(long long<< " bytes " << endl;
    cout << "sizeof(float) is " << sizeof(float<< " bytes " << endl;
    cout << "sizeof(double) is " << sizeof(double<< " bytes " << endl;
    cout << "sizeof(long double) is " << sizeof(long double<< " bytes " << endl;
    cout << "sizeof(bool) is " << sizeof(bool<< " bytes " << endl;
    return 0;
}
cs


sizeof는 크기를 반환합니다.


'c cpp' 카테고리의 다른 글

[c++] if, switch 조건문  (0) 2016.11.22
[c++] 자동형 변환, 강제형 변환  (0) 2016.10.22
[c++] 연산자  (0) 2016.10.22
[c++] 변수 선언  (0) 2016.10.19
[c++] 화면에 텍스트 출력  (0) 2016.10.19
Comments