[OT] An array of C-Strings
[OT] An array of C-Strings
- Subject: [OT] An array of C-Strings
- From: Sam Goldman <email@hidden>
- Date: Sat, 26 Jan 2002 20:22:21 -0800
Sorry for being off topic, but I don't have a C++ book yet
(recommendations?) and I need a pretty simple question answered.
I want to have an array of C-Strings (which as you know are arrays
themselves). The C-Strings in the array would be added at runtime and I
don't know how many there will be or how long each one will be.
Here's what I have come up with so far.
#include <iostream.h>
int main()
{
char **days;
char *word = "The length of the word would be variable";
int i;
for (i = 0; i < 7; i++)
{
days[i] = word;
}
for (i = 0; i < 7; i++)
{
cout << days[i] << endl;
}
return 0;
}
It compiles with gcc, but during runtime it quits with a Bus Error message.
Thanks,
Sam