for (i = 0; i<(strlen(arr1)+1)/2; i++)

只需将循环中的"i"在定义时定义为无符号即可,即unsigned i;

产生错误的代码:

#include
#include
#include
int main(){ char arr1[] = { "Welcome to bit!" }; int num = strlen(arr1); unsigned i; char arr2[20] = {"***************"}; printf("%s\n", arr2); for (i = 0; i<(strlen(arr1)+1)/2; i++) {  arr2[i] = arr1[i];  arr2[strlen(arr1) - i - 1] = arr1[strlen(arr1) - i - 1];  printf("%s\n",arr2); } system("pause"); return 0;}