Please can someone tell me why the code bellow make dev c++ crashes ?
FILE* input;
int k=0;
char filename[]="";
int* Tab=NULL;
printf("Please specify the filename you want to open and read\n");
scanf("%s",&filename);
//strcat(filename,".txt");
input=fopen(filename,"r");
if(input==NULL)
{
printf("File open error");
}
fscanf(input,"%d",&total);
Tab=malloc(total);
for(k=0;k<total;k++)// here is my problem
{
fscanf(input,"%d",&Tab[k]);
}
The file gets open normally and the read was correct at first atempt then it sddenly started crashing . the variable total
can be read as well the next for loop is the problem .
Any help Please ?