I'm writing a program that gets all the even integers in a txt file and outputs it to another txt file. I'm having trouble figuring out what to do.
Here's the code, i got the numbers, no how do I output it to a new file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
string filename = "hello.txt";
int x;
ifstream input;
input.open(filename.c_str());
if (!input)
{
cout << "ERROR : File" << filename << " cannot be opened" << endl;
input.close();
}
while (input >> x )
{
cout<< x << " ";
}
Quoting. What's wrong? You know how to read from a file, you should be able to write to another file.
You aren't having bugs or exceptions.
You probably just don't want to finish the code by yourself?