Creating Data File with C++

How can I go about creating a data file with the Dev C++ compiler?
If you post the whole assignment we might be able to help you.
Purpose: The purpose of this program is the following:
Read in the input file and organize the data inside from lowest to highest.
Send the new data into an output text file.
Close everything and reopen the output text file onto the screen.

How can I accomplish the above with the Dev C++ compiler? The code below is error-free, as far as I can tell.

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

#include <iostream>
#include <fstream>

using namespace std;

int main()
{	int a, b, c;
    ifstream fin("input.txt");
    ofstream fout("output.txt");
    
    fin >> a >> b >> c;
    cout << a << b << c <<endl;
    while (a != -1)
        
    {
       
    if(a<b && b<c)
        fout<<a<<" "<<b<<" "<<c<<endl;
    else if(b<c && c<a)
        fout<<b<<" "<<c<<" "<<a<<endl;
    else if(c<a && a<b)
        fout<<c<<" "<<a<<" "<<b<<endl;
    else if(b<a && a<c)
        fout<<b<<" "<<a<<" "<<c<<endl;
    else if(c<b && b<a)
        fout<<c<<" "<<b<<" "<<a<<endl;
    else if(a<c && c<b)
        fout<<a<<" "<<c<<" "<<b<<endl;
        
        fin >> a >> b >> c;
    }
    
    fin.close();
    fout.close();
    fin.open("output.txt");
    fin >> a >> b >> c;
    while (!fin.eof())
    {
        cout << a << b << c <<endl;
        fin >> a >> b >> c;
        

    }
    fin.close();
    return 0;
}
Topic archived. No new replies allowed.