void main()
{
int number;
totalCallsPtr pcall=NULL;
getData(&pcall,&number);
}
void getData(totalCallsPtr* pcall,int* number)//get data from the text file
{
int i,n;
FILE *f1;
f1=fopen(INPUT, "r");
if (f1==NULL)
printf("File not open!\n");
else
{
fscanf(f1,"%d",&n);
*pcall=((totalCallsPtr)malloc(n*sizeof(CALL)));
}
if((*pcall=(totalCallsPtr)malloc(n*sizeof(CALL)))==NULL)
printf("not enough memory to allocate");
for(i=0;i<n;i++)
{
fscanf(f1,"%d ",&pcall[i]->day);
fscanf(f1,"%d:%d:%d ",&pcall[i]->startCall.hours,&pcall[i]->startCall.minutes,&pcall[i]->startCall.seconds);
fscanf(f1,"%d:%d:%d ",&pcall[i]->endCall.hours,&pcall[i]->endCall.minutes,&pcall[i]->endCall.seconds);
fscanf(f1,"%c",&pcall[i]->type);
}
free(*pcall);
*number=n;
}
why doesnt it work for me?