I have a struct of char arrays defined as follows:
struct SD_Data {
char time[8];
char vac[4];
char vdc1[4];
char vdc2[4];
char freq1[4];
char freq2[4];
char freq3[4];
char error_status[4];
char run_status[10]; };
struct SD_Data sdData;
// data is put into struct here...
I want to use a variable within a loop that corresponds with the size of each array.
Normally I can use:
size = sizeof(sdData.time);
size = sizeof(sdData.vac);
etc
Is there a way to replace the name with a pointer instead and increment the pointer as it gets the sizes of each array?
I have tried by defining a pointer to the start of the strut and then getting the sizeof the deferenced pointer but only gives the size of the pointer
int* numPtr = (int*)&sdData;
size = sizeof(*numPtr );
Thanks.