Rod said:
True. Crap is useful, it can be made in to fertiliser. What you have
posted is worse than useless, it is dangerous because some poor innocent
who does not know any better might believe you. You've obviously still
not read the FAQ.
Actually, it agrees with me completely.
C&V. Here is a quote from the standard which defines the term "array type".
| An /array type/ describes a contiguously allocated nonempty set of
| objects with a particular member object type, called the /element
| type/.36) Array types are characterized by their element type and by
| the number of elements in the array. An array type is said to be
| derived from its element type, and if its element type is T, the
| array type is sometimes called 'array of T'. The construction of
| an array type from an element type is called 'array type
| derivation'.
Why would it define an array type if arrays don't exist? Can you quote
anything that says they don't?
Nope. Unless you can quote something in the standard that says arrays
are not arrays.
"char
RP> mstr[10]", mstr or mstr[] is thought of as an array.
Because it is except when it is the declaration of a parameter to a
function.
No, it's not.
C&V? I'll give you a clue, there isn't one.
But, [] is
actually a
RP> subscript operator which functions on pointers only.
True. Fortunately the name of an array gets automatically converted to a
pointer in this situation.
Incorrect.
It's what the C standard says. Are you saying the C standard is wrong?
To be precise the standard says:
| Except when it is the operand of the sizeof operator or the unary &
| operator, or is a string literal used to initialize an array, an
| expression that has type 'array of type' is converted to an
| expression with type 'pointer to type' that points to the initial
| element of the array object and is not an lvalue. If the array object
| has register storage class, the behavior is undefined.
This seems to agree with what I said about when the subscript operator
is used.
Correct, because it is a pointer to a const type (remember preallocated
storage?), i.e., the pointer can't be changed.
This is explicitly addressed in section 6 of the FAQ and you've
obviously failed to read it.
<snip>
I'm ignoring the rest of the also incorrect drivel.
So you are going to ignore all the bits in the C FAQ that point out your
error, and the part where I pointed out that code relying on what you
claim will fail to compile and if forced through with a cast does not work.
Here is a nice simple example where a compiler is *required* to produce
a diagnostic *because* arrays are not the same thing as pointers.
#include <stdlib.h>
int main(void)
{
int a[5];
int *p;
if (&a == &p)
return EXIT_FAILURE;
else
return 0;
}
You can add in const in as many places as you want and the compiler will
continue to complain because it is *required* to. Of course, it is not
required to fail to compile, only to produce a diagnostic.
This is all covered in section 6 of the comp.lang.c FAQ, so here is a
link directly to it since you could not be bothered to read the
questions without a link. I expect you read them this time as well, but
any newbie following this thread will have the chance to read it and see
that you are wrong.
http://c-faq.com/aryptr/index.html