Hi everyone,
I am writing a function that will read int numbers from a file and store the numbers into an array, but I an having a hard time with it. on of the problems being that I need it to return the number of items stored in the array when it is done, so that i can use it in another function,
Below is the code. Any pointers and help would be greatly appreciated.
#include <stdio.h>
int* readtopps (char fn[]){
int data[];
int n,i;
FILE* fp;
fp=fopen(fn,"r");
fscanf(fp,"%d",&n);
data=(int*)malloc(sizeof(int)*n);
for (i=0;i<n;i++)
fscanf(fp,"%f",&data[i]);
fclose(fp);
return(data);
}
now, I thougth of making it return a structure containing an int(numofelems) and an array(cardnum), but how would i do that?