例如:
struct myCar{
int price;
int *uniqueID;
};
Run Code Online (Sandbox Code Playgroud)
在C中,int有4个字节.我假设一个指针也占用了4个字节?因此,总共8个字节?
找出:
printf("Size of my struct is: %zu\n", sizeof(struct myCar));
Run Code Online (Sandbox Code Playgroud)
指针的大小取决于平台.就此而言,a的大小int取决于平台.如果您使用的是64位计算机,则可以是8个字节.