0

Why this code has no output?

char *str = "12345"; printf(" %s", *str);

21st Apr 2020, 5:20 PM
Ashfaq Reshad
Ashfaq Reshad - avatar
1 ответ
+ 4
*str means you are dereferencing a character, at the address pointed by pointer <str>. The problem here is you are using %s which is meant for string rather than character. Use %c instead of %s and you will get output. Use %s if you want to print the string, but don't use dereference operator '*', -> printf(" %s", str);
21st Apr 2020, 5:30 PM
Ipang