Thread: Read text from a file into an array

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    5

    Read text from a file into an array

    I have to write a program that reads a file consisting of students' test scores in the range of 0-100. They are just listed in a .txt file.

    I'm supposed to make a function called readScores that reads the test scores from a file into an array. How do i go about writing this function, I'm stuck. I'm confused with the array part and how to put it into the array. Thanks in advance.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Hi,

    1)Try writing a program that puts the numbers 0-9 into an array using a for-loop? Try it, and if you get stuck, post the code you have.

    2) Write your function to read all the scores into a single variable. Then, use what you learned from 1) to make some modifications.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Reading in an array of text from a file?
    By suzakugaiden in forum C++ Programming
    Replies: 6
    Last Post: 01-04-2006, 03:17 PM
  3. read from .txt file & put into array?
    By slow brain in forum C Programming
    Replies: 6
    Last Post: 02-25-2003, 05:16 AM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM