For more information, visit: http://www.xcoder.cn
The function of ansi c only supports passing by value, but does not support transferring by reference. However, the pointer operation can simulate passing by reference. In fact, it is the value of the passed pointer, the function uses a pointer to modify the value of the pointer to the address:
# Include <stdio. h> <br/> # include <ctype. h> <br/> void converttouppercase (char *); <br/> void main () {<br/> char string [] = "characters and & 32.98 "; <br/> printf ("the string before conversion is: % s", string); <br/> converttouppercase (string ); <br/> printf ("/nthe string after conversion is: % s/n", string); <br/>}< br/> void converttouppercase (char * sptr) {<br/> while (* sptr! = '/0') {<br/> If (islower (* sptr) <br/> * sptr = toupper (* sptr ); </P> <p> sptr ++; <br/>}< br/>}
The running result is as follows:
the string before conversion is: characters and $32.98 <br/> the string after conversion is: characters and $32.98