+ 2
What is the output of this and how??
Char *s={"12345"}; Printf("%s",*s);
2 Answers
+ 1
s is a pointer to a character type, which is initialized with the address of the string "12345".
*s is the value of the location the pointer is pointing to, which happens to be a mere character. To be printed you use %c.
%s specifier requires an array or pointer of type char as argument
It throws error at compile stage. So no output.
To get output then
printf("%s", s);
Or
printf("%c", *s);
printf("%d", *s);
0
printf("%d",*s);
This prints the character code of the first char in the string, in this case "1" which will print "49". This is similar to using print(ord('1')) in Python.
printf("%s",s);
This prints the actual string. "12345"



