有十个字符串每个字符串表示一段文字将十个字符串链接成一篇文章保存到一维数组并输出c语言程序
时间: 2023-08-13 22:08:18 浏览: 47
以下是一个示例程序,将十个字符串链接成一篇文章,并输出到屏幕上:
```c
#include <stdio.h>
#include <string.h>
int main() {
// 十个字符串
char str1[] = "Lorem ipsum dolor sit amet, ";
char str2[] = "consectetur adipiscing elit. ";
char str3[] = "Sed euismod metus vel sapien ";
char str4[] = "ultrices, vel malesuada lectus ";
char str5[] = "auctor. Quisque nec nisi sed ";
char str6[] = "sem rutrum placerat. Aliquam a ";
char str7[] = "purus auctor, bibendum magna ";
char str8[] = "id, lobortis metus. Sed sagittis ";
char str9[] = "neque at erat blandit, vel ";
char str10[] = "consequat justo feugiat.";
// 将十个字符串链接成一篇文章
char article[1000];
strcpy(article, str1);
strcat(article, str2);
strcat(article, str3);
strcat(article, str4);
strcat(article, str5);
strcat(article, str6);
strcat(article, str7);
strcat(article, str8);
strcat(article, str9);
strcat(article, str10);
// 输出文章
printf("%s", article);
return 0;
}
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)