#include <stdio.h>
#include <stdlib.h>
void reverseStr(char* x)
{
int slen;
char* buf;
char* p;
char* p2;
p = x;
while(*p) ++p;
slen = p - x;
buf = (char*) malloc(slen + 1);
p = x; p2 = buf;
while(*p) *(p2++) = *(p++);
*p2 = 0;
p = buf;
p2 = x + slen;
*p2 = 0;
--p2;
while(*p) {
if (*p < 0) {
*(p2 - 1) = *p;
*p2 = *(p + 1);
++p;
--p2;
} else {
*p2 = *p;
}
++p;
--p2;
}
free(buf);
}
int main()
{
char x[] = "abcd我是个好同志";
reverseStr(x);
puts(x);
return 0;
}
还要能搞中文啊,你的要求略麻烦……