為什么不能連續(xù)的進(jìn)行復(fù)制,在處理字符串時(shí)。
#include <stdio.h>
#include <string.h>
int main()
{
??? char s1[100];
??? char s2[]="我愛,";
??? char s3[]="慕課網(wǎng)";
??? strcat (s2,s3);
??? strcpy (s1,s2);
??? printf("%s\n",s1);
??? return 0;
??? }為什么s1不能輸出結(jié)果
2016-12-19
注意,char s2[]里需要字符長度,你沒給他,所以可以在里面加個(gè)長度
? ? ? ? ? ?char s2[20]; ?這樣就行。
2016-12-17
#include <stdio.h>
#include <string.h>
int main()
{
??? char s1[100];
??? char s2[]="我愛,";
??? char s3[]="慕課網(wǎng)";
??? strcpy(s1,s2);
??? strcat(s1,s3);
??? printf("%s\n",s1);
??? return 0;
??? }