From file to integer array

This is a discussion on From file to integer array within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm trying to passing values from a text file to an array. The values in txt file is; 0 ...

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    1

    From file to integer array

    Hi,

    I'm trying to passing values from a text file to an array. The values in txt file is;

    0 2 3 5
    1 2 5
    0 1 3 6
    1 3 5

    I need to store these values in an array like that
    Code:
    int array[?][?]={{0,2,3,5},{1,2,5},{0,1,3,6},{1,3,5}};
    any idea?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    Read every line. Push a new line into vector.
    Parse every line and push back integer into a vector.

    You may want to read up about 2d vectors.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Integer Array Please help
    By jj121 in forum C Programming
    Replies: 10
    Last Post: 05-18-2010, 01:26 PM
  2. integer array to char array?
    By DJPlayer in forum C Programming
    Replies: 4
    Last Post: 10-19-2009, 10:59 PM
  3. integer pointer to an array[][][]
    By jordanguyoflove in forum C Programming
    Replies: 16
    Last Post: 12-23-2008, 12:19 PM
  4. Reading Input from file (Integer array)
    By Govalant in forum C Programming
    Replies: 9
    Last Post: 07-23-2007, 07:13 PM
  5. Converting character array to integer array
    By quiet_forever in forum C++ Programming
    Replies: 5
    Last Post: 04-02-2007, 06:48 AM

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