简体   繁体   中英

Initializer-string for char array is too long

I have read char four[4] = "four"; What are the correct semantics for this statement?

I am using Xcode and writing Objective C code. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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