c语言编程 将10个字符串长度小于20字符串连接起来,组成一个新的字符P,并输出

如题所述

#include <stdio.h>
#include <string.h>
void main()
{
char p[200]={NULL};
char str[20]={NULL};
int i;

for(i=0;i<10;i++)
{
printf("请输入第%d个字符串: ",i+1);
scanf("%s",str);
fflush(stdin);

strcat(p,str);
}

printf("\n组合后的字符串为: %s\n",p);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-12-25
字符串连接函数strcat(char a,char b),会将b的内容加到a后面去。