Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1118817
  • 博文数量: 241
  • 博客积分: 4385
  • 博客等级: 上校
  • 技术积分: 2383
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-07 23:13
文章分类

全部博文(241)

文章存档

2013年(1)

2012年(8)

2011年(62)

2010年(109)

2009年(61)

分类: C/C++

2009-09-29 10:31:58

#include
using namespace std;

void Swap(char &a, char &b)
{
 a ^= b;
 b ^= a;
 a ^= b;
}

char *MyStrrev(const char *str)
{
 char *temp = new char[strlen(str) + 1];
 strcpy(temp, str);

 char *tempAddress = temp;
 char *tempEnd = temp + strlen(str) - 1;

 while(tempEnd > temp)
 {
  Swap(*tempEnd, *temp);
  --tempEnd;
  ++temp;
 }

 return tempAddress;
}

int main()
{
 char *str = "abcd";
 str = MyStrrev(str);
 cout< return 0;
}

阅读(1354) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~