2011年12月2日
摘要: #include "stdafx.h"#include <stdio.h>int main(){unsigned int a = 0xFFFFFFF7; unsigned char i = (unsigned char)a;char *b = (char *)&a;printf("%08x,%08x",i,*b);getchar();return 0;}输出结果为:000000f7,fffffff7分析:unsigned int 变量赋值给unsigned char 3个字节将会被截断为1字节(3位和高于3位的将被程序自动丢弃)。第二 阅读全文
posted @ 2011-12-02 22:46 Ming明、 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 看到第五章程序员面试宝典里有题如下:#include "stdafx.h"#include <stdio.h>int _tmain(int argc, _TCHAR* argv[]){int b = 3;int arr[] = {6,7,8,9,10};int *ptr = arr;*(ptr++) += 123;printf("%d,%d \n",*ptr,*(++ptr));getchar();return 0;}输出结果为: 8,8相信很多人都做错了吧。分析如下:C中printf计算参数时,是从右往左压栈的。其中,*(ptr++)+=1 阅读全文
posted @ 2011-12-02 22:27 Ming明、 阅读(664) 评论(0) 推荐(1) 编辑
摘要: 看到第五章程序员面试宝典里有题如下:#include "stdafx.h"#include <stdio.h>int _tmain(int argc, _TCHAR* argv[]){int b = 3;int arr[] = {6,7,8,9,10};int *ptr = arr;*(ptr++) += 123;printf("%d,%d \n",*ptr,*(++ptr));getchar();return 0;}输出结果为: 8,8相信很多人都做错了吧。分析如下:C中printf计算参数时,是从右往左压栈的。其中,*(ptr++)+=1 阅读全文
posted @ 2011-12-02 22:26 Ming明、 阅读(112) 评论(0) 推荐(0) 编辑