C语言:在一个字符数组中先后存放多个字符串,是怎么存放,举例说明
2008-03-23
展开全部
#include <string.h>
char a[80];
//将"abcd"保存到a中
strcpy(a,"abcd");
//输出a中的字符串
puts(a);
//将"1234"保存到a中
strcpy(a,"1234);
//输出a中的字符串
puts(a);
char a[80];
//将"abcd"保存到a中
strcpy(a,"abcd");
//输出a中的字符串
puts(a);
//将"1234"保存到a中
strcpy(a,"1234);
//输出a中的字符串
puts(a);
展开全部
#include <iostream>
using namespace std;
int main()
{
char a[80];
strcpy(a,"abcd"); //首先把abcd赋值给数组a
cout << a << endl;
strcat(a,"1234"); //把1234补加给数组a
cout << a;
system("pause");
}
using namespace std;
int main()
{
char a[80];
strcpy(a,"abcd"); //首先把abcd赋值给数组a
cout << a << endl;
strcat(a,"1234"); //把1234补加给数组a
cout << a;
system("pause");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用 strcat
char str[1024];
strcpy (str,"these ");
strcat (str,"strings ");
strcat (str,"are ");
strcat (str,"concatenated.");
str 里有
"these strings are concatenated."
char str[1024];
strcpy (str,"these ");
strcat (str,"strings ");
strcat (str,"are ");
strcat (str,"concatenated.");
str 里有
"these strings are concatenated."
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询