While reading a binary file using DJGPP on DOS this code hangs. This happens when the fread call is made. If the call is removed then the program runs successfully. The same code runs fine through Visual C++ 2008. Has anyone experienced similar issues with djgpp ? Am I missing out on something really simple ?
char x;
string Filename = "my.bin" ;
fp = fopen(Filename.c_str(),"rb");
if (fp == NULL)
{
cout << "File not found" << endl ;
}
if (fseek (fp, 0, SEEK_END) != 0)
{
cout <<"End of File can't be seeked";
return -1;
}
if ( (fileLength = ftell(fp)) == -1)
{
cout <<"Can't read current position of file";
return -1;
}
if (fseek (fp, 0, SEEK_SET) != 0)
{
cout <<"Beginning of File can't be seeked";
return -1;
}
if (fread(&x,sizeof(x),1,fp) != sizeof(x))
{
cout <<"file not read correctly";
return -1;
}