C语言:定义两个字符数组 a[100],b[30]; 两个数组的初始字符不超过30个字符,请将b数组的字符接到a数组字符后面,并输出
源程序+结果截图
#include<stdio.h>
char *stringcnt(char *dest, const char *source)
{
int i, j;
for(i = 0; dest[i]; i++);
for(j = 0; source[j]; j++)
dest[i++] = source[j];
dest[i] = '\0';
return dest;
}
int main()
{
char a[100] = "C language is my ";
char b[30] = "Favourite language!\n";
printf("%s", stringcnt(a, b));
return 0;
}