main.h
#define DATA struct data
DATA
{
int id;
char data;
}
main.c
DATA *listOfData[100];
So at this
I'm not sure why printf
would just freeze, but there's a couple of things wrong with this. First, all the pointers in your DATA*
array are uninitialized. You probably intended to make an array of DATA
, instead of an array of DATA
pointers:
DATA listOfData[100];
You also didn't end the struct with a semicolon, so it seems unlikely that this would even compile:
#define DATA struct data
DATA
{
int id;
char data;
};
Finally, you're using printf
in a rather unsafe way; the first argument needs to be a format string, or you can get weird behavior if the first argument has a %
in it:
printf("%c\n", listOfData[5].data);