Mail Archives: djgpp/1997/06/24/13:21:59
Schuster wrote:
>
> Hi Dion!
> I'm not quite sure if the following helps, but give it a chance
> (though I tested it with a little program )...
>
> Try changing
> >// global storage buffer
> >char *wordBuffer[50];
> to
> char **wordbuffer;
> wordbuffer = new char* [50];
>
> Why don't you use the String class?
> I always do (if I write in C++ ), it's much easier.
>
> Hope this helps.
>
> Michi
> **********************************************
> Michael Schuster
> E-mail: Schuster AT eev DOT e-technik DOT uni-erlangen DOT de
> Lehrstuhl fuer Elektrische Energieversorgung
> http://www.eev.e-technik.uni-erlangen.de/
Thanks Michi,
I had to do a couple modifications to the above in order to get it to
work but you got me started on the right track. Another person's
reply filled in a very important piece of the puzzel. And with the
information provided by you two I figured it out. Thank you and in-case
you're reading this, thank you Günther. If you're wondering what I
ended up with here it is:
____________________________
char **wordBuffer[10000];
void SomeFunction(void)
{
char tmpBuffer[128];
int i = 0;
fstream fin("test.txt", ios::in | ios::nocreate);
if(!fin.is_open())
{
cerr << "unable to open file.... exiting";
exit(1);
}
do
{
fin >> tmpBuffer;
*wordBuffer[i] = new char [strlen(tmpBuffer) + 1];
strcpy(*wordBuffer[i], tmpBuffer);
cout << *wordBuffer[i] << ' ';
i++;
} while(!fin.eof());
fin.close();
}
_________________________________
Thanks again,
Dion
- Raw text -