c语言 请高手指教~~~~~~~~~~~

#include"stdio.h"
#include"string.h"
main()
{
char s1[80],s2[80];
int i;
printf("input s2:");
scanf("%s",s2);
for(i=0;i<=strlen(s2);i++)
s1[i]=s2[i];
printf("s1:%s\n",s1);
}
这个题如果输入 "jdak kjlj" 为什么只能输出 "jdak" 而"kjlj"输不出来?为什么空格后面的输不出来??/?请高手指教~~~~~~~~~~~~~

第1个回答  2019-02-03
static
静态变量先编译。然后是main()函数,依次编译。i是全局变量fun()函数会影响,其他变量各管各的。这些东西书上都有,好好看书
第2个回答  2006-11-06
下面的程序是根据你的要求修改过的,可以满足你的要求,中间可以加入任意个数的空格。

#include"stdio.h"
#include"string.h"
main()
{
char s1[80],s2[80],temp=NULL;
int i=0;
printf("input s2:");
while((temp=getchar())!='\n')
{
s2[i]=temp;
++i;
}
s2[i]='\0';
for(i=0;i<=strlen(s2);i++)
s1[i]=s2[i];
printf("s1:%s\n",s1);
getch();
}本回答被网友采纳
第3个回答  2006-11-06
scanf只读入了空格之前的字符给s2.
如果要在字符串中放空格,需要采用其他的方法,而不能通过scanf.
第4个回答  2006-11-06
空格是参数的分隔符
相似回答