2d Array int's

This is a discussion on 2d Array int's within the C++ Programming forums, part of the General Programming Boards category; Can anyone tell me if there is a fucntion or something that can read a line of integers, like getline ...

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359

    Question 2d Array int's

    Can anyone tell me if there is a fucntion or something that can read a line of integers, like getline reads characters?
    Thanks

  2. #2
    Unregistered
    Guest
    nope. Could read the following as a string with getline() and then parse by space and change resultant substrings to int using atoi():

    1234 5678 12378 765 1 0 9735

    If the above constituted values of data members in a struct/class and they were in a binary file, then you could use read() method to read them into the struct/class fields all at once. If, however, you wish to store them in separate unrelated variables, then you are best advised to use >> and read them out one at a time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cannot print out my 2d array correctly! please help
    By dalearyous in forum C++ Programming
    Replies: 5
    Last Post: 04-10-2006, 03:07 AM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Read file in 2D array
    By Chook in forum C Programming
    Replies: 1
    Last Post: 05-08-2005, 01:39 PM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 05:15 AM
  5. Replies: 6
    Last Post: 10-21-2003, 10:57 PM

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