• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[OT] An array of C-Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


  • Follow-Ups:
    • Re: [OT] An array of C-Strings
      • From: Brian Luft <email@hidden>
    • Re: [OT] An array of C-Strings
      • From: email@hidden
  • Prev by Date: Daemons!
  • Next by Date: Re: [OT] An array of C-Strings
  • Previous by thread: Re: Daemons!
  • Next by thread: Re: [OT] An array of C-Strings
  • Index(es):
    • Date
    • Thread