After I Prompt the user to get an integer from the keyboard, display the number on screen if it is an even number how do I write the number into a file in A:\ drive under the name OddFile.txt. if its odd.
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main ()
{
int num;
ifstream AFile;
AFile.open("a:\\OddFile.txt");
cout << "Enter an integer number please: ";
cin >> num;
if (num % 2 == 0)
cout << num << " is even\n";
else
AFile.open("a:\\OddFile.txt");
AFile.close();
system("pause");
return 0;
}