The barArray compiles fine, as it should.
The fooArray is giving me the error message: "error: too many initializers for 'char [4]'"
What is going on?
How can I define a multi dimensional char array [like fooArray] that compiles?
char stations[][2] = {
{"http://icecast.omroep.nl:80/radio1-bb-mp3", "NPO Radio 1"},
{"http://icecast.omroep.nl:80/radio2-bb-mp3", "NPO Radio 2"}
and many more...
So I should make sure that all these strings are '\0' terminated.
Is that what you are saying?
String literals are read-only, the correct type is [b]const[/b] char *fooArray[][2]. You probably don't want to lose the pointers to these strings, so you should probably also make the array itself read-only: [b]const[/b] char *constfooArray[][2].
Nice try!
But when I use this declaration:
Code: [Select]
char *stations[9][2] = {
{"http://icecast.omroep.nl:80/radio1-bb-mp3", "NPO Radio 1"},
{"http://icecast.omroep.nl:80/radio2-bb-mp3", "NPO Radio 2"},
I get just as many: "warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]" as there are elements in the array.
So, it's not as easy as that.