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.
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.