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 | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
