简体   繁体   English

char数组的初始化字符串太长

[英]Initializer-string for char array is too long

I have read char four[4] = "four"; 我读过char char [4] =“ four”; What are the correct semantics for this statement? 该语句的正确语义是什么?

I am using Xcode and writing Objective C code. 我正在使用Xcode并编写Objective C代码。 I don't understand why: 我不明白为什么:

char words[4] = { "aardvark", "abacus", "allude", "zygote" };

gives a warning 发出警告

warning: Semantic Issue: Initializer-string for char array is too long 警告:语义问题:char数组的初始化字符串太长

but

char *words[4] = { "aardvark", "abacus", "allude", "zygote" };

works fine. 工作正常。 Kindly guide me. 请指导我。

I was not aware of the differences between an integer pointer and a character pointer. 我不知道整数指针和字符指针之间的区别。 Hence, I was confused. 因此,我感到困惑。 This helped me: http://www.computing.net/answers/programming/why-this-works-char-pointer-in-c/4444.html 这对我有帮助: http : //www.computing.net/answers/programming/why-this-works-char-pointer-in-c/4444.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM