2011.12.3返回类型为指针的函数

#include <iostream>
#include <string.h>
using namespace std;

char b[80];
char *result = b;
char *convert(char *p1)
{
 
//  char *result;
//  char b[80];
//  result = b;
 unsigned short temp = strlen(p1);
 unsigned short i = temp - 1;
 p1 += i;
 for(int j = temp;j > 0; j--)
 {
  *result++ = *p1--;
 }
 *result += '\0';
 result -= temp;
 return result;
}
int main()
{
 char a[80];
 char *p = a;
 cin>>p;
/* char *p = "abc";*/
 cout<<convert(p)<<'\n';
}

posted @ 2011-12-03 22:46  rookieeeeee  阅读(146)  评论(0编辑  收藏  举报