Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要创建一个结构的内存模型,我需要找到在声明时为结构分配了多少内存。
struct student { int Roll_no,age; float average; float grade; };
除非我误解了你,否则内置的sizeof运算符/函数会做你想要的:
sizeof
size_t size_of_student_in_bytes = sizeof(student);