Thread: How to read in empty values into array from input file

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    9

    How to read in empty values into array from input file

    Hi, the problem I am trying to solve goes as follows:

    I am given a txt file with the following values:
    Code:
    251  383  346  209  432  232
            342  909  423  102  238  203
    23    34    33    93     88   90    
    38    48    76    54     56   49
    I spaced it so you can see what I am talking about.

    I would like to store the values into a 7 X 4 array, but my problem is I do not know what to do with the blank values. (The values can not be set to 0) Is there essentially a way to store those blanks values so that they do not count? Also I need to be able to accept various input files not just the one given. (Other input files may have blank spaces as well).

    Any suggestions?
    Thank you a lot for your time and help.


    [code][/code]tagged by Salem
    To show spaces in the file

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Sorry the values did not come out the way I wanted it to look. Basically its a 7X4 array but has blank spaces at various spots.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    Sorry one more mistake. It's a 4 X 7. I got the rows and columns mixed up. Thanks again for your help.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    how is the file set up up? Is it a comma delimited file where spaces are represented by back to back commas if first and last ?

    4,134,,56,21,,70

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    no. there are no comments, just blank spaces where there is no value.

  6. #6
    Registered User
    Join Date
    Oct 2002
    Posts
    9
    commas, by bad... i need to proofread better.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  2. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 08:09 PM