val*_*e55 -5 c string pointers
void main(){
char str1[10] = "Hello", str2[10] = "World";
printf(5 + "Good Morning\n");
}
Run Code Online (Sandbox Code Playgroud)
它将输出显示为“早上”,我不明白为什么,提前致谢。
在对整数加法的上下文中,数组"Good Morning\n"(type char[14]) 被转换为指向其第一个元素 (the 'G')的指针。
该指针增加 5,因此指向'M'.
好 _ 早上好 \n
0 1 2 3 4 5 6 ...
在printf()接收到该字符串"Morning\n"的格式串。因为它没有%,所以可以直接打印。
| 归档时间: |
|
| 查看次数: |
94 次 |
| 最近记录: |