I'm having some problems getting the this code to work. It's supposed to take a text file, load it into the buffer in paragraphs, assigned to a vector, convert the vector to an array, and then replace a specific word in those paragraphs.
But the problem I'm having is array[0] gives a value but array [1] doesnt or [2], possibly they are assigned in memory to array[0]? My final goal to get this program to work would be to convert the paragraphs stored in the array into char type so I can replace the specific words and cout to the user. Could someone help me?
It's supposed to take a text file, load it into the buffer in paragraphs, assigned to a vector,
Doesn't make sense. getline reads each line of the file. Each string in your vector will be one line from the text file up to the carriage return unless you specify something to override the default delimiter which is '\n'. You could reach each sentence using '.' as the delimiter assuming that the text in the file is grammatically correct.
Don't use EOF in your loop. the program has a serious flaw. Read this. You want to put the getline call inside the while loop. It returns the stream so that you can implement a check of whether the call failed or succeeded. http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5
would be to convert the paragraphs stored in the array into char type so I can replace the specific words and cout to the user.
You don't need to convert anything. The vector is an array of string objects and each string is already encapsulating a char array which can be easily modified using the std::string member functions.
Thank you, I used some of your suggestions and they improved the program. But for some reason I would still have three lines of text output for array block [0] while nothing out output to console for array block [1] or [2]. And then at array block [3] I would get another 3 lines of text. It's like the array was chunking together at every 3rd block. I thought since an array has one less container then a vector that could be my problem.
What I ended up doing was manually copying the text into code separating paragraphs as case statements. And using switch/case in a do while loop to get the paragraphs I want to output to console.