您的位置:首页 > 编程语言 > C语言/C++

经典问题2:c/c++ 程序设计 ---i++问题

2009-10-10 20:21 204 查看
-------------------------------------------------------------------

经典问题2:c/c++ 程序设计 ---i++问题

-------------------------------------------------------------------

1)面试题:What will be the output of the following C code?

1 #include <stdio.h>

2

3 int main()

4 {

5 int b = 3;

6 int arr[] = {6,7,8,9,10};

7 int *ptr = arr;

8 *(ptr++) += 123;

9 printf("%d,%d/n ",*ptr,*(++ptr));

10 return 0;

11 }

------------------------------------

result:

在函数‘main’中:

9: 警告: ‘ptr’上的运算结果可能是未定义的

5: 警告: 未使用的变量‘b’

----------

$ ./a.out

8,8

------------------------------------

知识点:printf();语句是从右往左运算;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: