|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
c:
- #include <stdio.h>
- #include <string.h>
- void print_byte_content(int);
- int main()
- {
- int value;
- short before=1920;
- short after=1080;
- memmove((char*)&value,(char*)&before,2);//低位
- memmove((char*)&value+2,(char*)&after,2);//高位
-
- print_byte_content(before);
- print_byte_content(after);
- print_byte_content(value);
-
- int width=value<<16;//低位往高位移
- print_byte_content(width);
- width=width>>16;//高位往低位移
- print_byte_content(width);
-
- int height=value>>16;
- print_byte_content(height);
- return value;
- }
- void print_byte_content(int data)
- {
- int len;
- int byte;
- printf("int %d 内存地址上的内容为:\n",data);
- for (len=0;len<sizeof(data);len++)
- {
- printf("%d:\t",len);
- for (byte=7;byte>=0;byte--)
- printf("%d",(*((char*)&data+len)&(1<<byte)) != 0);
- putchar('\n');
- }
- }
复制代码
bat内容:
- @echo off
- 0410.exe
- set value=%errorlevel%
- set /a height="value>>16"
- set /a width="value<<16"
- set /a width="width>>16"
- echo height=%height%
- echo width=%width%
- pause
复制代码
结果:
- int 1920 内存地址上的内容为:
- 0: 10000000
- 1: 00000111
- 2: 00000000
- 3: 00000000
- int 1080 内存地址上的内容为:
- 0: 00111000
- 1: 00000100
- 2: 00000000
- 3: 00000000
- int 70780800 内存地址上的内容为:
- 0: 10000000
- 1: 00000111
- 2: 00111000
- 3: 00000100
- int 125829120 内存地址上的内容为:
- 0: 00000000
- 1: 00000000
- 2: 10000000
- 3: 00000111
- int 1920 内存地址上的内容为:
- 0: 10000000
- 1: 00000111
- 2: 00000000
- 3: 00000000
- int 1080 内存地址上的内容为:
- 0: 00111000
- 1: 00000100
- 2: 00000000
- 3: 00000000
- height=1080
- width=1920
- 请按任意键继续. . .
复制代码
|
|