#include
#include
#include
void fun(char* str)
{
char *begin = str;
char *end = str + strlen(str);
char *front, *back, tmp;
for( front=begin, back=(end-1); front
tmp = *front;
*front = *back;
*back = tmp;
}
}
void main()
{
char str[200];
printf("请输入字串闷带: ");
gets( str );
fun( str );
printf("反辩雀转后蚂灶芦: %s\n", str );
}
12345abcde
edcba54321
Press any key to continue
#include <腔凳stdio.h>
#include "string.h"
void fun(char *buf)
{
char str[100]="\伍桐旅0";
int i,j=0;
for (i=strlen(buf)-1;i>=0;i--)
str[j++]=buf[i];
printf("%s\n",str);
}
main()
{
char buff[100]="\0";
gets(buff);
fun(buff);
}
有问题请追问 满轮晌意记得采纳
#include
using namespace std;
char* fun(char *s){
char* start = s;
char* end = s+strlen(s)-1;
while(start < end){
char tmp = *start;
*start = *end;
*end = tmp;
start++;
end++;
}
return s;
}
int main(){
char* str = "hello world!"弯亩;
fun(str);
cout<档闹弊
}