字符数组中拷贝多字节的变量后查看是如何来存储的 布局

来源:互联网 发布:余国荔 知乎 编辑:程序博客网 时间:2024/05/18 00:41

/*
* =====================================================================================
*
*       Filename:  arr_oper.c
*
*    Description:  在字符数组中拷贝多字节的变量后查看是如何来存储的
*
*        Version:  1.0
*        Created:  2010年11月29日 13时00分09秒
*       Revision:  none
*       Compiler:  gcc
*
*         Author:  Yang Shao Kun (), cdutyangshaokun@163.com
*        Company:  College of Information Engineering of CDUT
*
* =====================================================================================
*/

#include
#include
#define VOTE_REQ 0XA9
int main(int argc, char **argv)
{
    unsigned char buf[8];
    memset(buf,0,8);
    unsigned int len=65535;
    memcpy(buf,&len,sizeof(unsigned int));
    int le;
    le=sizeof(unsigned int);
    memcpy(buf+le,&len,le);
    int i;
    for(i=0;i<8;i++)
    printf("%d /n",buf[i]);
     return 0;
}

运行后的结果

QQ截图未命名结果不解释。呵呵!

原创粉丝点击