char *a = "bla"
a
: is a char*
, and you should use %s
for printf(...)
;
a[1]
is equivalent to *(a+1)
, then a[1]
is a char
, and you should use %c
for printf(...)
;
&a[1]
is equivalent to &(*(a+1))
, then &a[1]
is a char*
, and you should use %s
for printf(...)
;
This is more like a pointer question. To better understand how pointers work, think this way:
char *j;
j
is a char*
*j
is a char
, and equivalent with j[0]
*(j+1)
is a char
, and equivalent with j[1]
&(*j)
is achar*
, and equivalent with &j[0]
, equivalent with j
&j
is a char**
Another example:
char j**
j
is a char**
*j
is a char*
**j
is a char
, and equivalent with *(*(j+0)+0)
, and equivalent with j[0][0]
&j
is a char***
and so on...