Thread: 2d Array int's

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

    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, 02: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, 12:39 PM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. Replies: 6
    Last Post: 10-21-2003, 09:57 PM