Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!noao!amethyst!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.lang.c Subject: Re: More 2D array woes... Message-ID: <1002@caslon.cs.arizona.edu> Date: 4 Mar 91 00:38:14 GMT References: <1991Mar3.235114.12154@nntp-server.caltech.edu> Organization: U of Arizona CS Dept, Tucson Lines: 27 In article <1991Mar3.235114.12154@nntp-server.caltech.edu> eychaner@suncub.bbso.caltech.edu writes: >Here we go again, warm up the flame guns... > >Ok, suppose I have an array like > char strings[NUMBER][SIZE]; >How do I add more strings to this array, i.e. make it larger, portably and >easily. I can't realloc it, since it's not a pointer! Argh! It's beginning to sound like what you really want is C++. In C++, you can simulate arrays cleanly using pointers, and thus you can use realloc to increase (or decrease) the size of your array dynamically. You could even program it so that accessing an element beyond the end of your array automagically made it bigger. C is good for writing quick, reasonably simple (at least as far as data structure manipulation goes) programs. When you find you need some heavy-duty data structures, like dynamically sized arrays, or associative arrays, you should seriously consider moving to C++. The learning curve is kind of steep (even for C-literates), but ultimately a useful tool to be able to use. -- Dave Schaumann dave@cs.arizona.edu 'Dog Gang'! Where do they get off calling us the 'Dog Gang'? I'm beginning to think the party's over. I'm beginning to think maybe we don't need a dog. Or maybe we need a *new* dog. Or maybe we need a *cat*! - Amazing Stories