DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

字串反轉

11.13.2008
| 1678 views |
  • submit to reddit
        // description of your code here

#include <stdio.h>
#include <stdlib.h>

int ind = 0;

void stringReverse(char *c)
{
if(c[ind] != '\0')
{
char tmp = c[ind];
ind++;
stringReverse(c);
printf("%c", tmp);
}
}

void main()
{
char in[100];
printf("輸入字串:");
scanf("%s", &in);

printf("反轉後:");
stringReverse(in);

printf("\n");
system("pause");
}