Re: newbie...please help
- From: "Bart" <bc@xxxxxxxxxx>
- Date: 11 Jan 2006 14:17:29 -0800
Andrew Poelstra wrote:
> Bart wrote:
> char animals [ ] [3][6] = {
> > > "cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram","bee","doe"}
> > I don't get this either. A 3D array is declared then initialised with
> > 2D content. Am I missing something? It works better without the [3] and
> > the [1].
> >
> Because a string is in itself an array, a 2D array of strings would
> actually be a 3D array.
> That's why you shouldn't learn C without programming experience: It's
> hellishly complicated.
>
> Ex. animals[0][0][0] == 'c', whereas animals [0][0] = "cow" and animals
> [0] = [the address in memory of "cow"]
>
I think I get it now, the init data should have looked like:
{{"cow","pig","dog"},{"rat","bat","hen"},{"eel","ant","cat"},{"ox","owl","yak"},{"ram","bee","doe"}};
instead of the linear:
{"cow","pig","dog","rat","bat","hen","eel","ant","cat","ox","owl","yak","ram","bee","doe"};
but the 'magic' of C makes that correct.
Bart
.
- References:
- newbie...please help
- From: cj
- Re: newbie...please help
- From: Bart
- Re: newbie...please help
- From: Andrew Poelstra
- newbie...please help
- Prev by Date: Re: the buffer question of the stdio
- Next by Date: Re: seeking web tutorials for writing compiler
- Previous by thread: Re: newbie...please help
- Next by thread: Re: newbie...please help
- Index(es):
Relevant Pages
|