I'm writing a program in c++ and I need to ask the user for a file name, print the file and then reprint it with every 5th word missing. I've gotten as far as to asking them file name, checking for errors and printing out the file, I'm just completely lost on how to reprint it with every 5th word missing, any help?
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
using namespace std;
int main()
{
const int SIZE = 51;
char fileName[SIZE];
char ch;
ifstream inFile;
bool lastWasLetter = true;
const string UNDERLINE = "__________";
cout << "Please enter a file name: ";
cin >> fileName;
inFile.open (fileName, ios::in);
while (!inFile)
{
cout << fileName << " could not be opened, please enter new file name: ";
cin >> fileName ;
inFile.open (fileName, ios::in);
}
inFile.clear(); // reset read pointer to very beginning of file
inFile.seekg(0L, ios::beg);
std::string word;
int count = 0;
while (inFile >> word)
{
count++;
if (count % 5 != 0)
cout << word << endl;
}
}
And yes this a project I'm working on for my programming class.