how about   std::vector<std::string>   and go from there.  save yourself a
lot of headaches

At Thursday 2004-12-30 22:56, you wrote:


>How can I create an array of strings in C/C++ ? I can use an array
>of pointers for a finite number of strings like MAXSIZE as char
>*array[MAXSIZE-1]; Can I use a pointer to pointer char **array; for
>infinite number of strings? If that is the case how will I
>initialise the char ** ?
>
>Follows the code I am trying....
>
>class DynamicStringArray
>{
>
>         private:
>             char **ptrptr;  //I am usinng char ** instead of char *[]
>             int position;
>
>         public:
>         DynamicStringArray()
>         {
>                 ptrptr=0;position=0;
>         }
>         void addString(char *ptr)
>         {
>            ptrptr[position]=new char(strlen(ptr) +1); //crash here
>            strcpy(ptrptr[position],ptr);
>            position ++;
>         }
>         void displayString(int data)
>         {
>                 cout<<"String at "<<data<<"is:"<<ptrptr[data]<<endl;
>         }
>
>};
>
>This program is crashing at addString() function at first line.
>
>Please help me in this regards,
>
>Pratheesh.
>
>
>
>
>
>
>
>
>
>To unsubscribe, send a blank message to
><mailto:[EMAIL PROTECTED]>.
>Yahoo! Groups Links
>
>
>
>

Victor A. Wagner Jr.      http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law"



To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.


Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to