0
    #include<iostream>
    #include<fstream>
    #include<string>
    #include<windows.h>

    using namespace std;

    void mainMenu();
    void viewtable();

int main()
{
    mainMenu();
    return 0;
}

void mainMenu()
{
    int num;
    char ch='y';
    while(ch=='y'||ch=='Y')
    {
        do
        {
            system("cls");
            if(cin.fail())
            {
                cout<<"Invalid Input..."<<endl;
                cin.clear();
                cin.ignore(500,'\n');
            }
            cout<<"\t\t|DLSL CURRENCY EXCHANGE PROJECT  |"<<endl;

            cout<<"\n\n";
            cout<<"1-View Latest Global Currency Exchange Rate\n";
            cout<<"2-Update Currency Rate\n";
            cout<<"3-Currency Converter\n";
            cout<<"4-Exit Application\n";
            cout<<"\n\n\n";
            cin>>num;
        }
        while(cin.fail());

        switch(num)
        {
            case 1:
                {
                    viewtable();
                }
                break;
            default:
                {
                    cout<<"wrong input";
                }
        }
        cout<<"\nIf you want to Repeat Press Y and N for Exit\n";
        cin>>ch;
    }
}

void viewtable()
{
    system("cls");
    ifstream file;
    string line;
    file.open("currency.txt");
    while (getline (file, line))
        cout << line << endl;
    }
> here is the txt file:
> > AUD BRL CAD CNY DKK EUR HKD INR JPY RUR SGD SEK CHF USD PHP
> > AUD 1   2.52    0.99    5.07    4.92    0.66    5.98    49.55   87.6    44.62   1.04    6.44    0.77    0.77    39.63
> > BRL 2.5 1   0.39    2.01    1.95    0.26    2.37    19.66   34.74   17.69   0.14    2.55    0.3 0.3 15.73
> > CAD 1.01    2.54    1   5.13    4.97    0.67    6.04    50.08   88.5    45.05   1.06    6.51    0.78    0.78    40.05
> > CNY 0.2 0.5 0.2 1   0.97    0.13    1.18    9.77    17.26   8.79    0.21    1.27    0.15    0.15    7.81
> > DKK 0.2 8.06    0.2 1.03    1   0.13    1.22    10.08   17.83   9.07    0.21    1.31    0.16    0.16    8.06
> > 
> > 
> > 
> 
> > 
> 

good day everyone, can somebody help me how to use text files in dev C++. we have a project for extra credit in school. Im making a currency exchange rate 1) view table 2)update the file(change currency rates) 3) make conversions(using the file if possible) .. im just a newbie learning new things :( TIA

2
Contributors
1
Reply
14
Views
1 Month
Discussion Span
Last Post by rproffitt
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.