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

-------------------------------------------------------------------
经典问题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();语句是从右往左运算;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章