#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