0

From the given situation, we can say that we are able to declare array of structure in different ways. As I conclude, the difference is space optimization, namely the following:

struct { /* 1600 bytes */
    int a, c, e;
    char b, d;
} array_of_struct [100];

As is indicated at the top of the code, this takes up 1600 bytes. While this one

struct { /* 1400 bytes */
    int a[100], c[100], e[100];
    char b[100], d[100];
} struct_of_array;

takes only 1400 bytes. My question is that, when we are using such kind of things in real applications, is there any semantic difference between them? Optimization is good, but is it possible to change the main idea of code, when we declare array of structure into different forms?

4

0 に答える 0