✅ 목표 (Goal)

sizeof 연산자에 대해서 알아보자.

✅ sizeof 연산자란?

대상체의 바이트 크기를 알고 싶다면

sizeof 연산자를 사용하면 된다.

sizeof()가 함수처럼 보이지만, 연산자라는 것도 깜박하지 말자.

#include <stdio.h>

int main() {
	char a = 'a';
	int b = 123;
	float c = 3.141;
	double d = 2.718;

	int size_of_a = sizeof(a); // or sizeof(int)
	int size_of_b = sizeof(b); // or sizeof(int)
	int size_of_c = sizeof(c); // or sizeof(float)
	int size_of_d = sizeof(d); // or sizeof(double)

	printf("a size is %d\\r\\n", sizeof(a));
	printf("b size is %d\\r\\n", sizeof(b));
	printf("c size is %d\\r\\n", sizeof(c));
	printf("d size is %d\\r\\n", sizeof(d));

	return 0;
}

Untitled

✅ sizeof(student_t) vs sizeof(*s)

sizeof(student_t)
sizeof(s1)

형을 줘야 하나? 참조를 줘야 하나?

length= (uint16_t)= sizeof(sgd_packet_t);

length= (uint16_t)= sizeof(packet);