Chinaunix首页 | 论坛 | 博客
  • 博客访问: 642593
  • 博文数量: 128
  • 博客积分: 4385
  • 博客等级: 上校
  • 技术积分: 1546
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-22 14:05
文章分类

全部博文(128)

文章存档

2012年(2)

2011年(51)

2010年(75)

分类:

2010-09-09 11:57:05

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char str_rev(char *s)
{
    
        char *d = s + strlen(s) - 1;
        char temp;
        while(d > s)
        {
                temp = *d;
                *d = *s;
                *s = temp;
                d--;
                s++;
        }
    
}

int main(void)
{
    char *string;
    string = (char *)malloc(20);
    if(NULL == string)
    {
        printf("malloc failure! \n");
        return 1;
    }
    memcpy(string, "hello boy", 9);
    printf("string = %s \n", string);
    str_rev(string);
    printf("string = %s \n", string);
    free(string);
    string = NULL;
    return 0;
}


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