+ 1

Why did the result turn out? (1)

char s[]="Sololearn"; int c=(s[1]==s[3]); Printf("%d", c);

6th Sep 2020, 7:49 PM
Vladimir Kushner
Vladimir Kushner - avatar
1 Réponse
+ 5
Remember array indexing starts at zero, so s[ 0 ] -> 'S' s[ 1 ] -> 'o' ... and so on. Since the characters at index one and three are the same, the comparison operator returns true, which is usually an integral value of one. That value is then printed to the console.
6th Sep 2020, 8:20 PM
Shadow
Shadow - avatar