Hi everybody!
Recent I encountered two problems.
First problem:
I used fread/fwrite function of the standard c, to read or write a structure like:
typedef struct
{
TUint8 i;
TUint8 j;
}Teststructure ;
to a file.when I debug program in simulator ,the file cursor move ahead 2 bytes but move ahead 4 bytes when in real device. So I try to write a TUint8 data to a file ,I find the file cursor move ahead 1 bytes no matter in simulator or real device. I describe in form code like below:
Teststructure * b;
FILE* fp = fopen(filePath,"wb");
fwrite( b;sizeof(Teststructure),1, fp);
//I suppose the file cursor start at 0;
TInt addr1 = ftell(fp);
In simulator
addr1 = 2;
In real device
addr1 = 4;
And another code
TUint8 i = 2;
FILE* fp = fopen(filePath2,"wb");
fwrite(&i,sizeof(TUint8),1,fp);
TInt addr2 = ftell(fp);
No matter in simulator or real device
addr2 = 1;
Who can tell me why this happen?
Another problem,
I write a TReal data to file:
TReal i = 0.22;
FILE* fp = fopen(filePath,"wb");
fwrite(&i,sizeof(TReal ),1,fp);
Then, I read this TReal data from file:
TReal j;
FILE* fp = fopen(filePath,"rb"):
fread(&j,sizeof(TReal),1,fp);
in simulator j = 0.22;but in real device the value of j was a incorrect value;
who can tell me why?
My platform is S60 2nd and IDE is VC++ 6.0

Reply With Quote

