please explain the type : char*

Apr 22, 2014 at 7:43am
char a[3] = "que";

Here array name (a), represents the address of first array element.
So array name is of type char*.

please explain the type : char*


Last edited on Apr 22, 2014 at 7:49am
Apr 22, 2014 at 8:07am
char a[3] = "que";

Here array name (a), represents the address of first array element.

The array name (a) may be used as the address of the first array element in certain circumstances. It is not, however, the address of the first array element.


So array name is of type char*.

array name is of a type we call an identifier. The variable named a has type char[3] (array of 3 char), not char* (pointer to char.)


This code will cause an error, by the way. The type of "que" (const char[4]) cannot be contained in a because a is too small.
Apr 22, 2014 at 8:12am
http://www.cplusplus.com/doc/tutorial/pointers

Look at Pointers and string literals
Last edited on Apr 22, 2014 at 8:13am
Apr 22, 2014 at 8:30am
thanks @cire @MiiNiPaa
Topic archived. No new replies allowed.