Mail Archives: djgpp/2004/04/05/08:15:10
Bill Cunningham <nospam AT nspam DOT net> wrote:
> I've seen this in either k&r2 or a C++ book. Can't remember which.
That's a symptom of a serious error in your approach to learning these
languages. You're utterly confusing yourself by trying to learn two
things at the same time and not distinguishing between them clearly.
Make sure you know what it is what you're trying to learn: C or C++.
For the moment, I suggest you lock away *all* your books that mention
C++ in their title and concentrate on learning C first. Only once you
actually mastered C you should get out the C++ stuff again and learn
that language.
> An array say char array1[]={};
You almost certainly won't have seen exactly this in any C or C++ book
of reasonable quality --- it's wrong, in both languages. You could
have seen
char array1[] = {1, 3, 5, 7};
though, which is valid code to initialize the array with a known set
of value whose length also determines the size of the array object.
Even so, it's still not valid to use an initializer in a function
argument declaration, i.e.
int ma(int np[] = {1,3,5,7})
would still be nonsense, at least in C.
> It's initializing an array to how a yet indetermined number of
> elements.
Such a thing doesn't exist. You can't initialize an object to a value
you don't know.
If at all, the above would create a zero-element array --- but that
would be completely useless, and is thus forbidden.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -