3 ms·
an empty struct has a size of 1 byte. struct Widget{ }; Widget widgets[256]; printf("%d %d", sizeof(widgets), sizeof(Widget)); prints out
by gruez 9y ago
an empty struct has a size of 1 byte.
struct Widget{
};
Widget widgets[256];
printf("%d %d", sizeof(widgets), sizeof(Widget));
prints out
256 1
if there are 0 elements, there are no issues because it's 0/x = 0.