output quesion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

output quesion

char *s = "a string"; char *p = s; while(*p++); printf("%d", (int)(p-s)); how output is 9?

6th Aug 2022, 7:40 AM
Achintya Raj
Achintya Raj - avatar
1 Answer
+ 2
s points to starting of string ; p points to end of string after while loop so s + 8 and post increment cause+1 (p-s) difference is 9
6th Aug 2022, 8:02 AM
Jayakrishna 🇮🇳