1.Waht wil be the output of the following C code?
#include <stdio.h>
main()
{
int arr[] = {6,7,8,9,10};
int *ptr = arr;
*(ptr++)+=123;
printf("%d,%d\n",*ptr,*(++ptr));
}
A.8 8 B.130,8 C.7,7 D 7,8
解析: 定义指针时,ptr指向数组的第一个元素。*(ptr++)+=123,ptr指针向后走一位。
注意,c中的printf是从右到左运算,也就是说,会先计算*(++ptr),因此,ptr又向后走一位,指到8。因此,选A