I'm a computer science major and I'm taking an intro to C++ programming course. I have to write a program that reads in the data from a .txt file and echoprint it, and also print the data again but with every fifth word with 10 underscores. I was able to achieve the first half (echoprinting it) but how would I be able to reprint it replacing evey 5th word with 10 uderscores. It's supposed to be a cloze test...
Note: I'll be using a const string UNDERLINE = "__________"
please e-mail me back if you can at <snipped email>
I'll paste in the code that I currently have, but I'm not sure how it'll show up here.
#include <iostream> // Include Standard I/O Libraries
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
char cloze[1100];
char ch;
const string UNDERLINE = "__________"
ifstream inFile;
cout << "Please enter a filename: " << endl;
cin >> cloze;
cout << "\n\n";
inFile >> ch;
inFile.open ( "cloze.txt" );
inFile.clear();
inFile.seekg(0L, ios::beg);
if ( !inFile )
{
cout << "Error opening file." << endl;
}
else
{
while ( inFile )
{
inFile.get(ch);
cout << ch;
}
} // end of else else
inFile.close();
return (0);
} // end of main