home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!mcsun!sunic!dkuug!daimi!u920496
- From: u920496@daimi.aau.dk (Hans Erik Martino Hansen)
- Subject: array initialisation
- Message-ID: <1992Dec18.135255.19302@daimi.aau.dk>
- Keywords: c,array,initialize,bla bla
- Sender: u920496@daimi.aau.dk (Hans Erik Martino Hansen)
- Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
- Date: Fri, 18 Dec 92 13:52:55 GMT
- Lines: 30
-
- Hello outthere in netland!
-
- In a program a friend is writing he needs an array of an array of ints.
- The number of elements is not fixed.
-
- This is how I would write the source:
- /* example.c */
- int **tank = {
- { 10,24,563,3245,234,52345,234,-1 },
- { 1,645,21,-1 },
- { 243,33,452,122,422,123,-1 }
- };
- ...
-
- I cannot make the compiler accept "example.c". But if I change the definition
- of tank to: int tank[][8] = ... it works fine. But I think this solution
- is ugly code, and definately not according to the spirit of C.
- Some of the elements could be very long, and some consist only of a few
- ints. Then a lot of unused memery is allocated, and even more important:
- you'll have to count the elements by hand.
-
- My question is simply: is there a way to do, what I intended to in example.c
-
- Please mail me directly, as I have no access to newsgroups during the
- holiday. Thanks in advance!
-
- Erik Martino Hansen | u920496@daimi.aau.dk
- Trige Parkvej 9,ST1 |
- DK-8380 Trige | "Information wants to be free!"
- Denmark |
-