Reading a file

This is a discussion on Reading a file within the C++ Programming forums, part of the General Programming Boards category; Okay well I have a file that reads bowling scores and it assumes that each person is taking turns its ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    4

    Reading a file

    Okay well I have a file that reads bowling scores and it assumes that each person is taking turns

    its formatted as so

    John
    Mary
    Derick
    Dougless
    7 2 10 7 3 9 1 9 0 9 1 5 5 9 1 5 3 6 4 8 1 10 7 2 10 10 9 1 8 2 9 1 4 4 9 1 5 3 10 6 4 10 5 2 10 8 2 4 4 4 4 8 2 10 10 0 7 10 5 5 7 2 3 5 10 9 1 8 2 7 8 1

    What I want to do is find out a way in which I can keep the names and numbers in a separate array for instances I have something as

    Name[0] = John
    Frame[0] = 7,2

    The thing is I am completly new the system IO for C++ can anyone help?
    Last edited by Fuyuki; 12-08-2005 at 08:02 AM.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Code:
    Frame[0] = 7,2
    1) All C++ statements end in a semi-colon
    2) You have to declare the type of the Frame array. If you declare it as an int type, then all the elments of the array have to int's. That means, you can assign int's to the elements of the array. However,

    7,2

    is not an int--nor any other recognizable type in C++.

    I suggest you forget about reading from a file for the time being. Instead, put all the scores into an array, and read the scores from the array. Once you get your program working that way, you can then tackle the problem of reading scores from a file.

    The thing is I am completly new the system IO for C++ can anyone help?
    It also looks like you are totally new to the concept of an array which is a basic data structure in any programming language, so doing some beginning programs using arrays would be the wiser course before attempting this program.
    Last edited by 7stud; 12-08-2005 at 09:05 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-22-2008, 12:19 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 01:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM

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