Defining an array of structures in C?

前端 未结 3 821
温柔的废话
温柔的废话 2021-01-22 17:51

main.h

#define  DATA  struct   data
DATA
{
  int id;
  char data;
}

main.c

DATA *listOfData[100];

So at this

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 18:44

    You haven't shown any memory allocation for the DATA *. Either declare your array as an array of struct data, like:

    DATA listOfData[100];
    

    or allocate memory dynamically and assign the pointers in your array.

提交回复
热议问题