
May 31st, 2004, 11:56 PM
|
|
Contributing User
|
|
Join Date: May 2004
Location: Adelaide, Australia
Posts: 880
 
Time spent in forums: 1 Day 14 h 15 m 25 sec
Reputation Power: 10
|
|
The inner dimension(s) of a multi-dimensional array need to be fixed, otherwise the compiler can't do its arithmetic to find the array elements.
Your declaration shoould be something like:
Code:
char prompt[][30]={{"String 1 here"},{"String 2 here"},{"And one last one...."}};
Note that this means you have to know the maximum length of the strings. Some compilers may give you an error if you get it wrong, but I wouldn't rely on that.
It will also allocate more space than you need.
Depending on what the array was for, you could use
Code:
char *prompt[]={"String 1 here","String 2 here","And one last one...."};
This just allocates enough space for the strings, but if you are modifying the data, it could be dangerous.
|