字符串反转reverse.c

#include<stdio.h>

void reverse(char s[])
{
 int c,j,i;
 for(i=0,j=strlen(s)-1;i<j;i++,j--)
 {
  c=s[i];
  s[i]=s[j];
  s[j]=c;

 }
}


int main()
{
 char s[]="abcdefg";
 printf("s[]=%s\n",s);
 reverse(s);
 printf("s[]=%s\n",s);

 return 0;
}

猜你喜欢

转载自blog.csdn.net/d1306937299/article/details/49508743