0

Anyone please explain this code :

char *str="12345"; printf("%s",*str); Output is :Abnormal program termination and some irrelevant message.

30th Dec 2019, 7:32 AM
Shubham kumar
Shubham kumar - avatar
1 Answer
+ 5
Use %s to print the string, second argument should be the pointer to the first character (str) Use %c to print a certain character from the string, second argument should be a char, obtained by dereferencing from pointer (*s) Use of inappropriate format specifier can cause problems, take care to choose the right format specifier 👍
30th Dec 2019, 7:56 AM
Ipang