[C++]memcpy 小记

#include   <stdio.h>
#include   <stdlib.h>
#include   <string.h>
int   main ()
{
     char   a  =  'a' ;
     char   b  =  'b' ;
     char   c  =  'c' ;
     char   d  =  'd' ;
     char   ac [4] = { a ,  b ,  c  ,  d };
     int   i ;
     memcpy (& i ,  ac , 4);
     printf ( "0x%x\n" ,  i );
     int   iNum  = ( a <<24) + ( b <<16) + ( c <<8) +  d ;
     printf ( "iNum: 0x%x\n" ,  iNum );
     getchar (); 
     }  

输出如下:

0x64636261
iNum: 0x61626364
posted @ 2015-09-26 21:23  MDGSF  阅读(108)  评论(0编辑  收藏  举报