用返回指针类型函数实现字符串连接函数strcat(),通过
⑴输入字符串s1和s2进行测试。
⑵将字符串“string”作为参数与s1和s2的连接后的结果调用函数strcat()实现连接。

用返回指针类型函数实现字符串连接函数strcat()
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- WaitIKnowYou 2022-06-09 23:24关注
#include <stdio.h> char* strcat(char* s1, char* s2) { char* p = s1; while (*s1 != '\0') s1++; while (*s2 != '\0') *s1++ = *s2++; *s1 = '\0'; return p; } int main() { char s1[50], s2[50]; gets(s1); gets(s2); printf("%s", strcat(strcat(s1, s2), "string")); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录