Thread: file to array

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    32

    file to array

    I am new to programing and was wondering how to read in a file of integers and then put those integers into an array?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Too broad of a question, so here's a broad answer. Read a line from the file using fgets. Parse the line using strtod, sscanf, or others.

    Oops. C++ board.

    Same thing, mostly. Read a line using getline (preferably into a std::string). Parse much the same or use std::stringstream.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM