全部博文(516)
分类:
2012-11-01 12:12:18
原文地址:面试1 作者:dingzerong
职位: linux c 开发 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* 被注释掉的代码是不成立的,编译不通过 */ #includeint main(void) { int a = 2; int b = 3; int c = 4; int *const n1 = &a; const int *n2 = &a; int const *n3 = &a; //n1 = &b; *n1 = 5; n2 = &b; //*n2 = 1; n3 = &b; //*n3 = 5; return 0; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 #include 2 3 int main(void) 4 { 5 int a[][3] = {1,2,3,4,5,6}; 6 int (*ptr)[3] = a; 7 8 printf("%d %d\n", (*ptr)[1], (*ptr)[2]); 9 ++ptr; 10 printf("%d %d\n", (*ptr)[1], (*ptr)[2]); 11 12 return 0; 13 } /* 输出 2 3 5 6 */