Two dimensional array that reads file input

This is a discussion on Two dimensional array that reads file input within the C++ Programming forums, part of the General Programming Boards category; Okay I'll be honest I have that moving turtle assignment.....and I DON'T WANT THE ANSWER TO IT.....all I want is ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    10

    Question Two dimensional array that reads file input

    Okay I'll be honest I have that moving turtle assignment.....and I DON'T WANT THE ANSWER TO IT.....all I want is a general direction as to how to start it and make the program read a file and then change the two dimensional array based the on the commands......because I'm at a loss how to best get started.....example code for a similar situation would probably help me a lot because then i'd have some type of reference material of very similar nature i can work from........



    Any tips, code example (of similar nature using a file and 2-D array), or suggestions are most welcomed, but please note I don't want the exact answer to this because that will not allow me to apply concepts i need to learn from this assignment.

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,691
    Well, it really depends on the type of file being read. If the file's content looks something like
    toe?finger?nail@head?brain?hair@stomach?torso
    Then it's pretty easy. Just iterate through the file's characters (you can read the file all at once, or char by char, either way works for this application). Have variables stating the location in the master array, and one stating the location in the nested array. As you iterate through the characters, just load them into the specified array element. When you hit a '?', bump the nested pointer, when you hit a '@', bump the master pointer. You can use the STL to make the arrays easier to handle.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    10
    Well it would be reading simple commands number with spaces like and one w/coma: 1 4 3 2 1 5,11 ....that kinda of file input...if you could make a piece of example code for me....it would make what your saying easier to understand please

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. Two Dimensional Array Input from Formatted Data
    By teedoff087 in forum C Programming
    Replies: 14
    Last Post: 04-29-2007, 02:46 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM

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