#include "stdafx.h"
#include <iostream>
using namespace std;
//字符串原地逆置
char *Reverse(char *s){
char *p = s;
char *q = s;
while(*q)
q++;
q--;
while(q>p){
char t= *p;
*p = *q;
p++;
*q = t;
q--;
}
return s;
}
int main(){
char m[]="abcdefg"; //注意这里不要用char m ="abcdefg";
char *n = Reverse(m);
while(*n){
cout<<*n++<<endl;
}
}
#include <iostream>
using namespace std;
//字符串原地逆置
char *Reverse(char *s){
char *p = s;
char *q = s;
while(*q)
q++;
q--;
while(q>p){
char t= *p;
*p = *q;
p++;
*q = t;
q--;
}
return s;
}
int main(){
char m[]="abcdefg"; //注意这里不要用char m ="abcdefg";
char *n = Reverse(m);
while(*n){
cout<<*n++<<endl;
}
}