C |字符串|问题6

null

#include<stdio.h>
int main()
{
char str[] = "GeeksQuiz" ;
printf ( "%s %s %s" , &str[5], &5[str], str+5);
printf ( "%c %c %c" , *(str+6), str[6], 6[str]);
return 0;
}


(A) 运行时错误 (B) 编译错误 (C) uiz uiz uiz 你 (D) 小测验 你 答复: (D) 说明: 程序没有错误。以下所有表达的意思都是一样的 &str[5] &5[str] str+5 由于编译器在访问数组元素之前将数组操作转换为指针,所以上述所有操作都会产生相同的地址。

同样地,下面所有的表达都是同一个意思。 *(str+6) str[6] 6[str]

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享