Help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
ofstream fout1;
ofstream fout2;

string fnameOdd;
string fnameEven;
int x;
int numEven(0);
int numOdd(0);

cout << "Enter name of file for odd integers: ";
getline(cin, fnameOdd);

fout1.open(fnameOdd.c_str(), ios::out);

cout << "Enter name of file for even integers: ";
  getline(cin, fnameEven);

fout2.open(fnameEven.c_str(), ios::out);

if(!fout1.is_open())
{
    cerr << "Unable to open file" << fnameOdd << endl;
    exit(10);
}

if(!fout2.is_open())
{
    cerr << "Unable to open file" << fnameEven << endl;
    exit(15);
}

cout << "Enter list of odd and even integers (followed by 0): " << endl;
cin >> x;
while (x != 0)
{

if (x % 2 == 0)
{
    numEven++;
}
else
{
    numOdd++;
}
}
fout1 << "File " << fnameOdd << " contains " << numOdd << " odd integers. " <<endl;
fout2 << "File " << fnameEven << " contains " << numEven << " even integers. " <<endl;

fout1.close();
fout2.close();

return 0;
}


I do not know how to output on the screen, I believe that i have written it to the file correctly but i dont know how to output it.
Topic archived. No new replies allowed.