C++ Question?

This is a discussion on C++ Question? within the C++ Programming forums, part of the General Programming Boards category; I am trying to modify some coding that I have already done so that it will read inputs from a ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    15

    C++ Question?

    I am trying to modify some coding that I have already done so that it will read inputs from a text file. The input file contains the choice of the currency and the amount. The program will write the output to another text file instead of display it on the screen.
    Below is what I'm and tring to modify..Thanks for your help!!!




    #include<iostream.h>


    double amount = 0.0; /*Stores user input*/



    int main()
    {
    cout<<"Currency Conversion"<<endl;

    cout<<"--------------------\n";

    cout<<"Enter the amount in US Dollar: "; /*Prompt user for amount*/


    cin>>amount; /* Read in the amount*/


    /*Convert the amount to each currency type and print it out*/



    cout<<amount<<" US Dollars = "<<amount/0.6072<<" Swiss Francs\n";
    cout<<amount<<" US Dollars = "<<amount/1.4320<<" British Pounds\n";
    cout<<amount<<" US Dollars = "<<amount/0.0081<<" Japanese Yens\n";
    cout<<amount<<" US Dollars = "<<amount/0.6556<<" Canadian Dollars\n";
    cout<<amount<<" US Dollars = "<<amount/0.8923<<" Euros\n";

    }

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Create an ofstream object -

    std::osftream os("t.txt");

    and then use os inplace of cout. You'll have to include <fstream>.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    that should help

    I think... That should help
    C++
    The best

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21