123456789101112131415161718192021222324252627282930313233
#include <iostream> using namespace std; void reverse(char*); int main(int argc, char *argv[]) { char s[80]; cout << "Please input your text: "; cin.getline(s, 80); cout << "Your Text is : " << s << endl; reverse(s); cout << "After change: " << s << endl; return 0; } void reverse(char *s) { char * end; for (end = s; *end; end++) {} char temp; while (s < end-1) { temp = *--end; *end = *s; *s++ = temp; } }