delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/16/14:20:38

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Simple C question (many should know this)
Date: Fri, 16 May 1997 09:27:04 -0700
Organization: Alcyone Systems
Lines: 40
Message-ID: <337C8AD8.2AA4DF3E@alcyone.com>
References: <5ldm5u$e59 AT news DOT interlog DOT com> <337B4306 DOT 2F681183 AT alcyone DOT com> <5lfj3j$r75 AT news DOT interlog DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gautam N. Lad wrote:

> My Ship array holds numbers, which are 40x25, another words, 1000
> numbers.
> I can write up the numbers one by one, but since I already have the
> numbers in
> separate files, I just want to combine it as one.
> I have 24 files with the numbers.  Get it now!?!

What you're trying to do is so foreign to C that the previous poster
didn't even understand what you were asking, I suspect.

As I said in a previous post, you're trying to assign the elements of the
two-dimensional array a row at a time (what you're calling a "file," which
has a different meaning in C), and this is not legal.  The only time, in
fact, the curly-brace assignment is legal is at initialization -- i.e., on
the same statement where you declare the array.  And in that case, you
must initialize the _entire_ array, not just a row.

> I never bothered to touch up on 2D arrays (of anything other than
> chars).  I had
> the following in mind:
> 
> BYTE Ship[24][1000] = {
> {0,0,0,...},
> {0,0,0,...},
> {0,0,0,...}.....
> {0,0,0,...}};
> 
> But I didn't try.  I now think this is it.

This will work.

-- 
       Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
                     Alcyone Systems /   web / http://www.alcyone.com/max/
San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
                                   \
                      "The future / is right there."
                                 / Bill Moyers

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019