jason wrote:
Your code is making it more confusing that it should be. all that pBuffer stuff is numbing. try replacingi get all what you said ,and do my program like bellow .but it doesn't work well, i wonder if ther is some other mistaken ,please help!
char * pBuffer;
with
myrecord *pRecord;
then you do:
pRecord = (myrecord *) rInfo.m_pBytes;
then:
DWORD fl_conv;
tempRec.id = SyncHHToHostDWord( pRecord->id );
conv = SyncHHToHostDWord( *(DWORD *) &pRecord->hh );
tempRec.id = *(float *) &conv;
strcpy(tempRec.info1,pRecord->info1);
strcpy(tempRec.info2,pRecord->info2);
that should more or less do what you're trying to do. in any case, the code you posted is WAY more complicated than it needs to be.
matt
record struct : { Uint32 id; float hh; char[10] info1; char[20] info2; } myrecord;my section getting data: char * pBuffer; DWORD * temp,temp1; pBuffer=(char *) rInfo.m_pBytes; temp=(DWORD*)pBuffer; temp1=*temp; *(DWORD*)&temRec.id=SyncHHToHostDWord(temp1);// here i get id which is dword pBuffer+=sizeof(DWORD); temp=(DWORD*)pBuffer; temp1=*temp; *(float*)&temRec.hh=SyncHHToHostDWord(temp1);// here i get hh which is float pBuffer+=sizeof(float); char *tt; long re; re=GetString( tt,pBuffer,strlen(pBuffer)); temRec.info1=tt; //here i get info1 pBuffer+=re; re=GetString(tt,pBuffer,strlen(pBuffer)); temRec.info2=tt;// here i get info2 long GetString(char * pdest,char* psrc,int len) //my function of getting string { int off=0; while ((*psrc!='\0')) { *pdest=*psrc; *pdes++;*psrc++; off++; } *pdest='\0'; return strlen(pdest); }
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/