f scanf to dynamic arrays in C
Hello, I have a problem whenever I try to read from a file to a dynamic array the values are just random.
Code:
int* aaNo;
int* bbKod;
int* ccPuan;
int* ddOffset;
aaNo=(int*)malloc(buffer * sizeof(int));
bbKod=(int*)malloc(buffer * sizeof(int));
ccPuan=(int*)malloc(buffer * sizeof(int));
ddOffset=(int*)malloc(buffer * sizeof(int));
//int aaNo[buffer],bbKod[buffer],ccPuan[buffer],ddOffset[buffer];
int line[100],o=0;
while(fgets(line,sizeof(line),veri))
{
fscanf(veri,"%d %d %d %d",&aaNo[o],&bbKod[o],&ccPuan[o],&ddOffset[o]);
o++;
}
this is the code and here is the file I want to read:
Why do I get random numbers? Pls help.