Correct.
Code:
if ((filename[strlen(filename)-1])=='\n')
filename[strlen(filename)-1])=='\0;'
Will do what you want.
This is a function that prints out data into numbered files. It's a bit different from your format, but you'll get the idea, I believe:
Code:
void printIt(long i, long j) {
char fname[20];
long k;
FILE *fpout;
ltoa(i, fname, 10); //makes a long int, into a string
strcat(fname, ".txt"); //adds the file extension I want
printf("\nFilename: %s", fname); //just a √
if((fpout=fopen(fname, "w"))==NULL) {
printf("\n Error opening level 0 output file - terminating");
exit(1);
}
for(k=0;k<j;k++) //prints out a small struct, you can ignore this part
fprintf(fpout, "%s %s %d\n", recs[k].id, recs[k].doc, recs[k].bill);
fclose(fpout);
}