#include <stdio.h> #include <string.h>

char *str_cat(char *s, char *t);

int main() { char s[80], t[80];

printf("请输入字符串s:");
gets(s);
printf("请输入字符串t:");
gets(t);

printf("拼接后的字符串为:%s\n", str_cat(s, t));

return 0;

}

char *str_cat(char *s, char *t) { char *p = s;

while (*p != '\0') {
    p++;
}

while (*t != '\0') {
    *p = *t;
    p++;
    t++;
}

*p = '\0';

return s;

}

C语言字符串拼接函数str_cat实现 - 用字符指针实现字符串连接

原文地址: https://www.cveoy.top/t/topic/pblt 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录