Thread: File Reading

  1. #1
    emiyca
    Guest

    Question File Reading

    Say I have a file like:

    2345##23
    4######3
    222#678#


    and say I want to give this file to main as an argument.
    and I want main to read the file and put the data
    in a multidimensional array like:

    int myarray[7][3];

    after the process myarray should contain data
    like this:

    myarray[0][0] will be 2
    myarray[0][1] will be 4

    and so on...


    how can I do it?

    thanks for helping

  2. #2
    Unregistered
    Guest
    you will either need to use a char array or ignore the # signs storing a default number in it's place.

    you need to use nested loops to read in the data in a sequential fashion.

    for(i \\etc.
    {
    for(j \\etc
    inputStream >> array[i][j];
    }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM