View Single Post
Old Oct 14th, 2005, 8:15 PM   #1
aznluvsmc
Hobbyist Programmer
 
Join Date: Aug 2005
Posts: 137
Rep Power: 4 aznluvsmc is on a distinguished road
Question about multidimensional arrays of strings

Hi,

I'd just like to know if the following two declarations to create an array of strings are equivalent to each other.

int main(void)
{
     char *strings1[5];
     char strings2[5][21];
}

From my understanding, strings1 is an array of 5 pointers-to-char and strings2 is an array of 5 arrays of 21 char elements. In both cases, I see that they can both hold strings but strings2 can only hold a string with a max size of 20 characters whereas strings1 can hold variable length strings using dynamic memory allocation. I guess the better question is, can strings2 be equivalently expressed as strings1 and vice-versa?

Sorry if this sounds like such a noob question but my understanding on creating arrays of strings is kind of fuzzy.
aznluvsmc is offline   Reply With Quote