반응형
sizeof 연산자란?
피연산자의 크기를 바이트 단위로 계산해서 반환하는 연산자이다.
배열에 들어가게되면 매우중요한 연산자로서의 역할을 하게 된다.
피연산자로는 상수,변수,자료형의 이름도 올 수 있다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | int main(void) { int num = 1234; printf("size of num: %d \n\n", sizeof(num)); printf("size of 1234: %d \n", sizeof(1234)); printf("size of 1234.0: %d \n", sizeof(1234.0)); printf("size of 0.1234: %d \n\n", sizeof(0.1234)); printf("size of char: %d \n", sizeof(char)); printf("size of short: %d \n", sizeof(short)); printf("size of double: %d \n\n", sizeof(double)); return 0; } | cs |
1 2 3 4 5 6 7 8 9 | size of num: 4 size of 1234: 4 size of 1234.0: 8 size of 0.1234: 8 size of char: 1 size of short: 2 size of double: 8 | cs |
반응형
'BackEnd > C' 카테고리의 다른 글
산술연산 과정에서 발생하는 형 변환의 규칙 (0) | 2018.12.18 |
---|---|
연산의 결과가 남기는것은? (0) | 2018.12.18 |
자료형 변환 연산자 (0) | 2018.12.10 |
관계연산자와 논리연산자 (0) | 2018.12.10 |
다양한 연산자들의 소개 (0) | 2018.12.10 |