写个C语言程序,两个数组char a[]="abc"和b[]="def"合并成数组c[]="abcdef"
时间: 2023-12-14 17:37:52 浏览: 77
将字符数组作为字符串变量-C语言超级好的资料
```c
#include <stdio.h>
#include <string.h>
int main() {
char a[] = "abc";
char b[] = "def";
char c[7];
strcpy(c, a); // 复制数组a到数组c
strcat(c, b); // 将数组b连接到数组c末尾
printf("%s\n", c);
return 0;
}
```
输出结果:
```
abcdef
```
阅读全文