接下来,我为大家展示的就是不用strcat函数进行字符串的链接
以下是源代码:
#include<stdio.h>
int main()
{
char a[]="My name is L ";
char b[]="I am seventeen";
int i;
printf("the string a:%s\n",a);
printf("the string b:%s\n",b);
for(i=0;a[i]!='\0';i++){
printf("%c",a[i]);
if(a[i]=='\0') goto L1;
}
L1:for(i=0;b[i]!='\0';i++)
printf("%c",b[i]);
printf("\n");
return 0;
}
主要通过一个goto函数进行跳转 当满足a[i]==‘/0’进行跳转到L1所定义的for循环中