求大神,哪里错了?
#include <stdio.h>
#include <string.h>
int main(void)
{
char word[10];
int length, index, temp;
printf ("please Enter a word:\n");
while (scanf("%s", word)==1)
{
length = strlen(word);//倒序打印
for(index=0; index<=(length+index)/2; index++) //二分 交换
{
temp = word[index];
word[index] = word[length-index];
word[length-index] = temp;
}
printf ("%s", word);
printf ("Do you want to continue?\n");
}
return 0;
}
为什么没交换?