I had a task to change every third symbol of a.txt file to symbol "a", and write the result to file b.txt. When I'm running the program b.txt results with a duplicated last symbol. I use f.get(a) command so that it would count spacebars also.
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
int i = 0;
ifstream f;
ofstream d;
char a;
f.open("a.txt", ios::in);
d.open("b.txt", ios::out);
while (!f.eof()) {
f.get(a);
i++;
d << a;
}
f.close();
d.close();
}