#include<stdio.h>
int main()
{
char a[5]="hello";
puts(a); //prints hello
}
为什么代码编译正确?我们需要六个地方来存储“hello”
,对吗?
最佳答案
C 编译器会让你运行数组的末尾,它不做那种检查。
关于c - 在C中将字符串存储在char数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2509221/
#include<stdio.h>
int main()
{
char a[5]="hello";
puts(a); //prints hello
}
为什么代码编译正确?我们需要六个地方来存储“hello”
,对吗?
最佳答案
C 编译器会让你运行数组的末尾,它不做那种检查。
关于c - 在C中将字符串存储在char数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2509221/