Suppose I have the following code:
main ()
{
char string[20];
printf(" The String is %s \n " , &str);
}
What would printf(" The String is %s \n " ,&str);
give?
Suppose str points to location 200, what would &str
give??
Suppose I have the following code:
main ()
{
char string[20];
printf(" The String is %s \n " , &str);
}
What would printf(" The String is %s \n " ,&str);
give?
Suppose str points to location 200, what would &str
give??
You should get a warning saying that
%s expects char* but argument 2 has char (*)[20] type.
The address is not printed, in fact nothing is printed.
Assuming you actually initialized the array with a string (which you didn't, but let's assume you did) then:
It is of type char (*)[20]
. It'll give the same output as
printf("The String is %s\n", str)
&str
points to the same memory location as str
but is of different type; namely pointer-to-array. The type of str
is of type pointer-to-char.