码迷,mamicode.com
首页 > 编程语言 > 详细

c语言使用指针实现模拟java/c# string.concat字符串串联方法

时间:2015-04-15 10:52:41      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
void _strcat(char *, const char *);

int main(void)
{
    char source[] ="View";
    char dest[] ="GoldenGolbal";
    _strcat(dest,source);
    printf("%s\n",dest);
}
//append string from source to dest
void _strcat(char * dest, const char * source)
{
    int j,i=0;
    
    while(dest[i] != \0)
    {
        i++;
        j = i;
    }

    i = 0;
    while(source[i] != \0)
    {
        dest[j+i] =source[i];
        i++;
    }
}

刚刚学c,看到别人写的这个代码,稍稍修改了一下贴出来分享

c语言使用指针实现模拟java/c# string.concat字符串串联方法

标签:

原文地址:http://www.cnblogs.com/passedbylove/p/4427703.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!