Let's say I had a .txt file called "textFile1," and I wanted to record 5 lines of text from it.
1. text
2. file
3. example
4. lines
5. here
Now, in my main file, I want to record the values of each individual line into an array such as string words[5];
How would I go about assigning words[0]'s value to "text", words[1] to "file" and so on, so on?
1 2 3 4 5 6 7 8 9 10 11
int main()
{
string words[5];
/*how to open; How to set the value of each words variable to the respective
*lines of textfile1?
*/
for(int i = 0; i < 5; i++)
{
cout << words[i];
}
}
I'm hoping to get the output "text file example lines here"