Hello everybody,
I wrote a program that can save some data into file and then read it from there,the weird thing is that it loads correctly from the file only when it's in debbug mode,and doesn't do it at all when it in release mode.
Here are the code fragment:
int extantion (char *buf)
{
int i;
for(i=0;((buf[i]!=NULL)&&(buf[i]!='.'));i++) ;
switch(buf[i])
{
case NULL:
{
buf[i]='.';
buf[i+1]='s';
buf[i+2]='a';
buf[i+3]='v';
buf[i+4]=NULL;
return 1;
}
case '.':
if((buf[i+1]=='s')&&(buf[i+2]=='a')&&(buf[i+3]=='v'))
return 1;
else
{
MessageBox(NULL,"Wrong extantion!"," message:",MB_OK);
return 0;
}
}
}
void SAVE (char *buf)
{
int i;
char *savename;
savename=buf;
ofstream savfile;
if((extantion(savename))==0) return;
savfile.open(savename);
savfile<<"SF"<<" ";
for(i=0;i<81;i++)
{
savfile<<save[i]<<" ";
}
savfile.close();
}
void LOAD(char *buf)
{
int i,check;
char ver[4];
char *loadname;
ifstream loadfile;
loadname=buf;
if((check=extantion(loadname))==0) return;
loadfile.open(loadname);
loadfile>>ver;
if(ver[0]=='S')&&(ver[1]=='F'))
{
for(i=0;i<81;i++) loadfile>>save[i];
loadfile.close();
succes='t';
}
else
{
MessageBox(NULL,"The file you want to load is not a Music Generator save file,or it doesn't exist!\n Action canceled.","Music Generator message:",MB_OK);
loadfile.close();
succes='f';
}
}
Can anyone explain to me please why the program doesn't load correctly when it's in release mode?
p.s.
I use VC++ 6.0