If each string is of same size which is known at compile time, say it is 100, then you can do this1:
typedef char cstring[100]; //cstring is a new type which is
//a char array of size 100
cstring *arrstring = malloc (1000 * sizeof (cstring));
int i;
for( i = 0 ; i < 1000 ; ++i)
strcpy(arrstring[i], "some string of size less than or equal to 100");
for( i = 0 ; i < 1000 ; ++i)
printf("%s\n", arrstring[i]);
Demo : http://ideone.com/oNA30
1. Note that as @Eregrith pointed out in the comment that cast is not advised if you compile your code as C. However, if you compile it as C++, then you need to write (cstring*)malloc (1000 * sizeof (cstring))
but then in C++, you should avoid writing such code in the first place. A better alternative in C++ is, std::vector<std::string>
as explained at the bottom of this post.
If the size of each string is not known at compile time, or each string is not of same size, then you can do this:
char **arrstring = malloc(sizeof(char*) * 1000); //1000 strings!
int i;
for(i = 0 ; i < 1000; ++i)
arrstring[i] = (char*) malloc(sizeof(char) * sizeOfString);
I'm assuming same size sizeOfString
for all 1000 strings. If they're different size, then you've to pass different value in each iteration, something like this:
for(i = 0 ; i < 1000; ++i)
arrstring[i] = malloc(sizeof(char) * sizeOfEachString[i]);
I hope that helps you, and I also hope you can do the rest yourself.
By the way, in C++, you should not do this:
string* arrayOfString = new string[10]; //avoid new as much as possible!
Instead, you should do this:
std::vector<std::string> strings;
strings.reserve(10);