This following line:
CurrentData *AllCurrentData = malloc(NUM_ITEMS * sizeof(CurrentData));
shall be:
CurrentData AllCurrentData = malloc(NUM_ITEMS * sizeof(*CurrentData));
Also replace this:
AllCurrentData[newLineCount]->data
with this:
AllCurrentData[newLineCount].data
Reason: your have typedef
ed CurrentData
to be an pointer to struct current
, and you could directly allocate AllCurrentData
as an array of struct current
.