I'm unable to resolve this error,please help me where i'm wrong, also please tell me how to use the GNU debugger because when i'm using it, "1.c is not an executable file" error occurs.
Here's the ADT file of my code :- Sparse.c
Here's my code:-
char filename[4];
int i,j,vectorCount=0;
refFile=fopen("x3.txt","r");
for(i=0; i<=100; i++){
fscanf(refFile,"%f",&x[i].value);
x[i].row=i;
x[i].col=1;
}
for(i=1; i<=10; i++){
sprintf(filename,"data/y%d.txt",i);
FILE *fptr=fopen(filename,"r");
y=newSparse(100,1,0);
for(j=0; j<100; j++){
fscanf(fptr,"%f",&y[j].value);
y[j].row=j+1;
y[j].col=1;
}
if(classCheck(x, y)==1){
vectorCount++;
}
}
You declare
char filename[4];
so filename
can contain filenames up to 3 characters long (4-1 because of the NUL terminator).
and later you have this:
sprintf(filename,"data/y%d.txt",i);
and "data/y%d.txt"
is obviously longer than 3 characters.
So declaring char filename[100];
should do the job.