Sorry for the lack of clarity, English is my second language and it can be difficult some times to specify what I need.
I have an assignment to write a c++ program where it: (1)Reads a text file and determines which words are even and which are odd (2)Then it takes even words and reverses the order of characters in each even word.
So for example I have a moderate size text. It picks out even words and reverses their character order.
So far I have written this code and I don't know if it is any good to continue with because I don't know how to reverse the order of characters. Thank you for the help.
#include <iostream>
#include <string>
#include <string.h>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
string word;
ifstream f("text.txt");
if (f.is_open())
{
while (f >> word)
{
if (word.length() % 2 == 0)
cout << word << endl;
}
f.close();
}
else
cout << "file is not open" << '\n';
}