[C언어] size_t 자료형이란?


[C언어] size_t 자료형이란?

size_t는 부호 없는 정수 자료형인데, sizeof 연산자나 offsetof 매크로의 결과이다. #include #include struct Data { char mode; int count; }; int main() { size_t size = sizeof(int); size_t offset = offsetof(struct Data, count); // size_t를 출력할 때는 서식 지정자에 z를 붙임 printf("%zd %zd\n", size, offset); return 0; } sizeof 연산자와 offsetof 매크로의 결과, size_t형 변수를 출력할 때는 서식 지정자에 z를 붙인다, 보통은 z를 붙이지 않고 %d로 출력하는데 C언어의 표준을 엄격하게 따르자면 %zd가 맞다. (8진..


원문링크 : [C언어] size_t 자료형이란?