C++ Loop for reading from file

This is a discussion on C++ Loop for reading from file within the C++ Programming forums, part of the General Programming Boards category; Objestive is to read in vales from a file (SSN, Number of courses, grades in each) then output to a ...

  1. #1
    datguy
    Guest

    C++ Loop for reading from file

    Objestive is to read in vales from a file (SSN, Number of courses, grades in each) then output to a file with SSN and GPA)

    Sample input from file
    365-67-4454
    5
    83 75 67 93
    95 89 88 90
    78 86 95 88
    98 95 86 91
    79 84 89 95

    The code I am wrestling with:

    char ssn[11];
    int homework;
    int quiz;
    int midterm;
    int final;
    int courses;
    int grade;
    double gpa;
    int i;
    int j;

    while (! inf.eof() )

    {

    inf.read(ssn, 11);
    inf>>courses;

    inf.read(courses, 10);
    {

    for (i=0; i<courses; i++)

    {
    int grades[4];

    for (j=0; j<4; j++);

    inf.read(&grades[j]);
    }
    }
    }

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    use code tags for one, n do your own hw for 2.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 07:26 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

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