Is it possible to create an array like this:
char name[] = {"Zed", "Roc", "Blanca"};
and then be able to:
printf("%s, %s and %s are my next-door neighbors.\n", name[0], name[1], name[2]);
I've tried it, but I keep getting errors on the array, saying "error: excess elements in char array initializer" and "error: (near initialization for ‘name’)" when I try to make the binary (did I use that right?).
I also get "warning: format ‘%s’ expects argument of type ‘char *’, but argument [2-4] has type ‘int’ [-Wformat]" Character strings get a %s as a format specifier, don't they?
I'm learning C for the first time. I have a background in JavaScript, so I know how to work with arrays, which is why I ask about this; what seems obvious to me doesn't seem to work. Different language, different rules, right?
I'm also using "Learn C the Hard Way" to learn. I'll laugh if this is something that will easily be explained next chapter (spoilers).