gpt4 book ai didi

c - 在C中将字符串存储在char数组中

转载 作者:行者123 更新时间:2023-12-05 01:24:01 25 4
gpt4 key购买 nike

#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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com