实现strcat功能,看下哪里错了?

#include<stdio.h>#include<string.h>int main(){ char a[100],w[100]; int i=0; int b=0,q; while((a[b]=getchar())!=✀尀n✀) b++; a[--b]=✀尀0✀; gets(w); for( q=b;q<b+strlen(w) ;q++) a[q]=w[i++]; a[b+strlen(w)]=✀尀0✀; for(i=0;a[i]!=✀尀0✀;i++) putchar(a[i]);}
2026年09月26日 21:35
有1个网友回答
网友(1):

根据你的函数意思,string_link应该是把str2接在str1后面,然后把str1作为结果输出,如果是这样, 1. 第一个循环应该是仅仅判断str1的'\0'在哪里,不应该赋值 2. 相等判断是==,不是一个= 完整函数是 void string_link(char str1[],char str2[])