Thread: arrays and files

  1. #1
    Registered User
    Join Date
    Oct 2001

    arrays and files

    ok here is the code i got
    	fin >> szMap[x][y];
    the problem is well alot of things i think... the file is initialised szMap[37][37]; and the length of the first and only line in map2.txt is 37 characters long and x and y are set to 0 for the time being... besides wondering how to fix the compile errors would this work? and how would i load say


    into array szMap[][] from a file? because the example i have posted only loads one line (that im aware of)

    thx for any and all help
    Last edited by c++.prog.newbie; 09-27-2004 at 11:10 PM.

  2. #2
    Registered User
    Join Date
    Sep 2004
    add the line - x++;
    at the end of your loop...

    and from my understanding y should be zero
       x   0  1  2  3       //x1 points (x1)y0...x2 points to x2(y0)...etc...
    0      L  L   x   e
    1      I  I    x   t
    2      N  N  x   c 
    3      E  E   x   .
    4      1  2   x   \0
    5     \0  \0  \0

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > while(!fin.eof());
    Why this is a "bad thing" is in the FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Oct 2001
    anyone know of a good file i/o tutorial because so far i have just been copying parts of examples...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Global arrays shared between multiple source files
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 08-14-2008, 06:29 PM
  2. reading integers into arrays from text files
    By c_beginner in forum C Programming
    Replies: 6
    Last Post: 08-05-2004, 11:42 AM
  3. reading files into arrays
    By SMB3Master in forum C Programming
    Replies: 12
    Last Post: 10-18-2003, 08:23 PM
  4. reading arrays from files
    By iain in forum C++ Programming
    Replies: 2
    Last Post: 12-05-2001, 01:23 PM
  5. writing arrays to files
    By Zaarin in forum C++ Programming
    Replies: 1
    Last Post: 08-30-2001, 11:26 PM