C++...sequential access data files

This is a discussion on C++...sequential access data files within the C++ Programming forums, part of the General Programming Boards category; Ummm....can someone help me? ? I'm trying to write a program using sequential access data files.....but i can't seem to ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    1

    Unhappy C++...sequential access data files

    Ummm....can someone help me? ?

    I'm trying to write a program using sequential access data files.....but i can't seem to figure out how to display multiple fields (more than two) in a table......that's the first problem

    The second one is that i can't figure out how to segregate the info in the data file so that the program will display only one line....for example, name.......money......day
    John $30.00 10
    Sam $40.00 5
    Joe $27.00 15
    ......so that i could have the program output that "the most money made in one day was Sam on day 5 for the amount of $40.00"


    Thnx in advance

    P.S.
    Yes, i am very new to this.

  2. #2
    Registered User
    Join Date
    Aug 2002
    Posts
    170
    This should let you do what you want. Write the data to the file on one line. Then read it back in. You will need to loop thru the reading the line to find the data you want.

    Code:
    string name;
    float amount;
    int day;
    
    fstream myfile("myfile");
    
    myfile << name << " " << amount << " " << day << endl;
    
    myfile >> name >> amount >> day;
    Best Regards,

    Bonkey

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. data structure design for data aggregation
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 05-20-2008, 07:43 AM
  2. Reading large complicated data files
    By dodzy in forum C Programming
    Replies: 16
    Last Post: 05-17-2006, 05:57 PM
  3. Replies: 26
    Last Post: 06-15-2005, 03:38 PM
  4. Reading data from consecutively named files
    By a1pro in forum C Programming
    Replies: 10
    Last Post: 04-15-2005, 02:48 AM
  5. Replies: 3
    Last Post: 09-22-2003, 10:48 PM

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