Finding min and max from file..

I'm trying to read 12 values in from a file (starting with the number 12) and output the max, min and average number. As you can see I haven't even gotten to the average part because I'm having trouble with the max and min.

The problem I'm having is that my program can't seem to find my data file or something like that (It's in the same folder with my source.cpp file). The output I get is just a bunch of rows of "-858993460 12"

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
#include <iostream>
#include <fstream>
#define in_file "data.txt"
#define out_file "result.txt"



using namespace std;
void main()
{
        ifstream ins;
	ofstream outs;

	ins.open(in_file);
	ins.open(out_file);

	int min = 12, max = 12, ave, num;
	ins >> num;
	for (int n = 1; n <= 12; n++)
	{
		
		if (num <= min)
				min = num;
		if (num >= max)
				max = num;
		
		cout << min << " " << max << endl;
		
	}
}
Do not open two files at the same time.
1
2
ins.open(in_file);
ins.open(out_file);


It should be :
1
2
ins.open(in_file);
outs.open(out_file);

Ah thank you very much. That was the exact problem.
Topic archived. No new replies allowed.