Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

CA.log

[C 프로그래밍] sizeof() 함수 본문

Programming/C

[C 프로그래밍] sizeof() 함수

TPOH 2022. 7. 8. 12:32
/* sizeof() */
# include <stdio.h>
# include <stdlib.h> // standard library
# include <limits.h> // data의 최대, 최소값 저장된 헤더파일

int main()
{
     int x;
     printf("%d\n", sizeof(x));      // 변수 : 4
     printf("%d\n", sizeof(char));   // char 타입 : 1
     printf("%d\n", sizeof(short));  // short 타입 : 2
     printf("%d\n", sizeof(int));    // int 타입 : 4
     printf("%d\n", sizeof(float));  // float 타입 : 4
     printf("%d\n", sizeof(double)); // double 타입 : 8
     printf("%d\n", sizeof(3));      // 정수(int로 인식) : 4
     printf("%d\n", sizeof(3.14));   // 실수(double로 인식) : 8
 
 	return 0;
}
Comments