I want to pass a struct array into a function, however, there's something wrong with how I'm passing it and I cant figure out what. I'll include the relevant code.
The Struct:
typedef struct fitbit
{
char patient[10];
} FitbitData;
Main.c:
FitbitData* data = (FitbitData*)malloc(sizeof(data) * 1450);
count = storeToksInArray(line, count, data);
function:
int storeToksInArray(char line[], int count, FitbitData* data[])
{
strcpy(data[count]->patient, strtok(line, ",")); //name
puts(data[count]->patient); }
I've already tested my code and there aren't any problems with line or count. The array works fine in my main file, but once I pass it into the function I can't get it to store the data correctly. The strcpy and puts functions work fine in main as well, so I'm 90% sure it's how I'm passing the array into the function and then using it in the function. I can also use the strtok and puts functions fine by themselves in the function, but once I try storing the token in the array, it doesn't work.
Edit: I figured it out! I removed the brackets after FitbitData data[] to get FitbitData data and then change -> to .**