C language: the content of the character array is: "student a am I", and the content is changed to "I am a student". Only a limited space can be opened.
# Include <stdio. h> void my_reverse (int len, char arr []) {int left = 0; int right = len-1; while (left <right) {char tmp = arr [left]; arr [left] = arr [right]; arr [right] = tmp; left ++; right -- ;}} int main () {char arr [] = "tneduts a ma I"; int len = sizeof (arr)/sizeof (arr [0])-1; my_reverse (len, arr ); printf ("% s \ n", arr); return 0 ;}
Returns the reverse output of the string. First, sizeof is different from strlen. The length is determined by the length of the string ending sign \ 0. The true String Length len is = sizeof (arr)/sizeof (arr [0]). -1; len-1 is also used when determining the right length. The void type here is because it only replaces the string address and does not perform other transformations, so no return value is required.