Advertisement

OT: File I/O (Lesson 10)

Started by August 17, 2001 02:10 PM
1 comment, last by Frank Henry 23 years, 6 months ago
hi, i''m using the same system nehe is using to load data from a file, the problem is, that fclose cannot close the file. am i missing something here? it loads the data perfectly, but wont close the file. i tried using flush and _fcloseall but nothing works. i''m using w2k sp2, ms visual studio .net 7 beta thanks in advance! here''s the code: void readstr(FILE *f,char *string) { do { fgets(string, 255, f); } while ((string[0] == ''/'') || (string[0] == ''\n'')); return; } int ReadNames (TypeNames &typeNames, RankNames &rankNames, FameNames &fameNames) { char oneline[255]; FILE *filein=NULL; filein=fopen("assets/Names.txt","rt"); if (filein) { memset(typeNames,0,sizeof(typeNames)); memset(typeNames,0,sizeof(rankNames)); memset(typeNames,0,sizeof(fameNames)); readstr(filein,oneline); sscanf(oneline, "%[^;];%[^;];%[^;];%[^;];%[^;];%[^\n]", &typeNames[0], &typeNames[1]...); readstr(filein,oneline); sscanf(oneline, "%[^;];%[^;];%[^;];%[^;];%[^;];%[^;];%[^\n]", &rankNames[0], ...); readstr(filein,oneline); sscanf(oneline, "%[^;];%[^;];%[^;];%[^;];%[^;];%[a-z ]", &fameNames[0], ...); fflush (filein); if (!fclose(filein)) MessageBox(NULL,"Failed Close File","ERROR",MB_OK|MB_ICONEXCLAMATION); fflush (NULL); _fcloseall (); } return 0; }
just noticed:
if i remove everything after if (filein) to fflush(filein)
everything works.
the problem was that after the data loading none of my textures where being loaded. with the above removed portion it works.
really annoying.

thanks again.
Advertisement
found my error, it was the memsetcall.
is there a sure-fire way to clear data?

thanks

This topic is closed to new replies.

Advertisement