본문 바로가기

Linux/C

[c] size_t의 포멧형식

sizeof( )를 결과값을 출력하기 위해서 코드를 작성 하고 리눅스 gcc 컴파일시 다음과 같은 경고를 보게 될 수도 있다. 이럴땐 포멧 형식을 printf("%zu" ,sizeof(long)); 으로 변경해 주자 sizeof는 size_t를 반환하는데 c99에서 size_t의 printf포멧이 %zu로 지정되었다. 

test.c:8:9: warning: format '%d' expects argument of type 'int' , but argument 2 has type 'long unsigned int'[-Wformat=]
   printf("long size : %d\n",sizeof(long));


'Linux > C' 카테고리의 다른 글

[c] gets( ) vs scanf( )  (0) 2018.01.31
[C] sizeof() vs strlen()  (0) 2017.03.18