Perhaps you could provide more sample code that should demonstrate your problem.
Help with VC files...

// My structure
struct struObj
{
__int16 iPosx, iPosy ;
__int16 iFrame, iMaxFrame;
__int16 iHp,iMaxHp;
__int16 iTipoObj,iDireccion;
__int16 iSpeedx,iSpeedy;
__int16 iTamX,iTamY,iValida;
};
struObj objTemp;
*FILE *fd;
// I create my file here
if ((fd=fopen("c:\\cheerio2.map","r+b"))==NULL)
{
//strcpy( CGame.sError, "Cant create map" );
}
objTemp.iPosx=64;
objTemp.iPosy=65;
objTemp.iFrame=66;
objTemp.iMaxFrame=67;
objTemp.iHp=68;
objTemp.iMaxHp=69;
objTemp.iTipoObj=70;
objTemp.iDireccion=71;
objTemp.iSpeedx=72;
objTemp.iSpeedy=73;
objTemp.iTamX=74;
objTemp.iTamY=75;
objTemp.iValida=76;
fwrite(&objTemp,sizeof( objTemp ), 1, fd );
fclose( fd);
// here I attemp to read it
if ((fd=fopen("c:\\cheerio2.map","r+b"))==NULL)
{
// strcpy( CGame.sError, "Error in cheerio2.map" );
}
fread(&objTemp,sizeof( objTemp ), 1, fd );
// check the values for objTemp after reading the file
fclose( fd);
Hope someone could help me..
I noticed that the file format you specify in your last post doesn't match the one you specified in the first post. Is your VB code outputting properly? Or could it be an error in your check to make sure the file read properly?
trying to open it in binary or text format, but I was getting the same error in both of them.
The output VB generates is equal to that VC does - with the fwrite posted before - my problem is
when I open the file. - Im checking directly the struct in the debugger -.
By the way I put my code before the statement that creates the mainwindow, does it affect in any
way?
Thanks!
FILE *fd;
char s[26];
if ((fd=fopen("c:\\cheerio.map","rt"))==NULL)
{
return 0; // errro opening file
}
fread(&s,sizeof( s ), 1, fd );
fclose( fd);
Lets say my file has:
@ A B C D E F G H I J K L
in binary
64 65 66 67 68 69 70 71 72 73 74 75 76
After reading the file I got:
0 85 64 65 66 67 68 69 70 71 72 73 74
I've tried to read it in binary and text form but it just doesnt work.. Any idea?
Laters and thanks!
Just to let you know that I was able to fix my problem with the VC files, I only had to remove the optimizations of my project and it suddenly worked.. this make wonder if you can't use optimizations at all in your debug version of any project??
Well, by now it's working thanks all and happy holidays!