I'm expecting h here.But it is showing g. Why?
char *c="geek";
printf("%c",++*c);
You are attempting to modify a string literal, which is undefined behaviour. This means that nothing definite can be said about what your program will print out, or indeed whether it will print anything out.
Try:
char c[]="geek";
printf("%c",++*c);
For further discussion, see the FAQ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With