Re: Keil c51 interprets &Array as Array. Is that normal?

On Apr 10, 9:59 am, "Bill Davy" <B...@xxxxxxxxxxxxxxx> wrote:
If I compile:

void Foo(void)
{ char Array[10]; char *p; p = &Array; }// Silly
{ char Array[10]; char *p; p = Array; } // Better
{ char Array[10]; char *p; p = &Array[0]; }// Some find this clearer


<snip asm>

Is this normal?
MSVC 6 issues a warning (C4047).

For which lines? Oh and does it report anything other than the number
or are we supposed to intuit the associated message ;)?

The first two are actually pointers to arrays of chars but those
devolve to pointer to char in context (A pointer to an array is a
pointer to the first member of that array). The first two are type
mismatches but the practical effect is only the type mismatch in most
situations. The first assignment is preferred by some people for the
clarity of explicitly indicating that you are taking the address of an
array. There are some additional error checking possible if the type
information is retained.

My memory is fuzzy on whether the second form is of the type pointer
to char or pointer to array of char. I think it's the latter.



Relevant Pages

  • Re: Problem with va_ macros and arrays of arrays
    ... > the arrays passed to a ... > specific char, somewhat similar to what the standard function ... that with an array of struct, or possibly a pointer to a dynamic array ... > As I'm still a beginner in C without a copy of the standard I ...
  • Re: Difference between Char* ptr and char arrCh []
    ... I have a few queries regarding array of characters using array ... notation and pointer notation. ... Is there a difference in storage of global char* and char* inside ...
  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
  • Re: Returning pointer to array problem II
    ... Iam trying to make program were I enter string and serach char. ... and funktion prints out witch position char is found this is done if funktion serach_char. ... so far all good what I want do next is: return, from funktion, pointer value to array were positions is stored. ...
  • Re: Simple question on Pointers
    ... int main ... It stores 12 char and only 12 ... pointer to the first element of the array with type pointer to element ...