#Meta-Wlp: #Macro: TITLE wlp: Learn C (IV) p. 5
Remember: the first character of string s is s+0, character number zero!
#include<stdio.h> int make_me_upper( char * s, int from, int count ) { int delta ; delta = 'a' - 'A' ; while (count--) { *(s+from) -= delta ; from++ ; } } int main(){ char * t ; t = "Why must you shout so loud" ; make_me_upper(t, 13, 5 ) ; printf ("%s?\n",t) ; }Why does the while loop terminate? #Shuffle: none $PAGE$-A $PAGE$-B $PAGE$-C Return to Learn C Table of Contents #: Because count is the constant 5. You can't change a constant, so it exits the function. #: Because you get the the end of the string and the function must terminate. #: Because the local variable count has its value set initially to 5. The fifth time through the loop it is zero, which is considered false. #: