OT: File I/O (Lesson 10)
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement