Array of Strings in C++ help ->

Joined
Apr 20, 2010
Messages
1
Reaction score
0
Welp, I have this project in which I must read in the contents of file, specifically each word block by word block. And I can accomplish this well enough.

I setup a string x;
and then have a While loop:

While(InFile>>x)
{
cout<< x <<endl;
}

This part of the project works fine. I can read the entire file and display it. But the next part has baffled me for a week. I want to read the file and retrieve each word string, but as x retrieves each string, I want to push the content of X into an array of strings (which in this case should contain each individual string word block of the file under each of its elements by the time the file has been traversed) And then I will hopefully be able to traverse that string array after the file has been read with a For Loop.

So Recap:
- read from a file >done
- but how to push the strings of the file one by one into an array of strings which can be traversed later >not so done.

And that's it, anybody have an idea? Your time is much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top