浮点型(FLOAT)与CHAR型转换

浮点(FLOAT)转换为CHAR

  float wTemp=3.3;
   char sBuf[4];
   char* temp;
   memset(sBuf,0,sizeof(sBuf));
   temp=(char*)(&wTemp);
   sBuf[0] = temp[0] ;
   sBuf[1] = temp[1];
   sBuf[2] = temp[2];
   sBuf[3] = temp[3]; 

CHAR转换为浮点(FLOAT)

  char sBuf[4];
  sBuf[0]=0x33;
  sBuf[1]=0x33;
  sBuf[2]=0x53;
  sBuf[3]=0x40;
  float *w=(float*)(&sBuf);

 

Trackback: http://blog.csdn.net/sijigang/article/details/1546117 

http://blog.csdn.net/liangwei88624/article/details/6885803 

posted @ 2011-12-01 00:00  大有|元亨  阅读(2900)  评论(0编辑  收藏  举报