Re: char* argv[]



William Pursell said:

<snip>

A pointer to an array of characters is a pointer to
the first element.

No, it isn't; they have different types, as this program will demonstrate.

#include <stdio.h>

int main(void)
{
char arr[13] = "Hello, world"; /* array of characters */
char (*parr)[13] = &arr; /* pointer to array of characters */
char *pch = arr; /* ptr to first element, eqvt to &arr[0] */
printf("%lu\n", (unsigned long)sizeof *parr);
printf("%lu\n", (unsigned long)sizeof *pch);
return 0;
}

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages