Sorry for that dumb question but how can I know the actual size of a structure with severals members in it.
For example here is my struct :
typedef struct mastruct mastruct;
struct mastruct{
int val;
char *chaine;
float decimal;
}__attribute__((packed));
and the affectation :
mastruct hello =
{
23,
"Hello world!",
3.141592654
};
printf return me this :
printf("int : %d, char* : %d, float : %d\n", sizeof(int), sizeof(char*), sizeof(float));
printf("struct size : %d\n", sizeof(hello));
int : 4, char* : 8, float : 4
struct size : 16
which is normal because int + char* + float = 16 bytes but this is not what I want. I want to know the complete size of the structure in memory.
For example if I'm writing "Hello world!!!!!!!!!!!!!!!!!!!!!!!" instead of "Hello world!" this would modify the footprint memory and I need to know that.
With this example if I'm printing the size of the struct I still get 16 bytes :
mastruct hello =
{
23,
"Hello world! Hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
3.141592654
};