#include <iostream>
using namespace std;
// this function is used to reverse a string
void reversestring(char* str)
{
if(str == NULL)
return;
char* head,*tail;
head = str;
tail = str;
while(*tail != '/0') tail++;
tail--;
char tmp;
while(head!=tail)
{
tmp = *head;
*head = *tail;
*tail = tmp;
tail--; head++;
}
}
int main()
{
char s[] = "abcdefghi";
reversestring(s);
cout<<s<<endl;
}
请大家指正!