Sportica   Sportica

C 把一个字符串倒序输出

#include <stdio.h>
#include <string.h>

int main()
{
char str[] = "abcde";
char temp[] = "";
int i, j;
for(i = 0; i<5; i++)
{
temp[i] = str [4-i];
}
strcpy(str, temp);
printf("%s\n",str);
}

结果:

# gcc test_point.c -o test_point
# ./test_point
str:edcba
posted @ 2012-03-22 20:42  qingjoin  阅读(15295)  评论(1编辑  收藏  举报
  Sportica