getchar(void)函数和scanf在输入时的区别

scanf函数在读取输入时,读取到空格就会结算读取,所有输入的内容不能有多个空格!
例:
char str[255] = " "
scanf(“%s”,str)–输入 “ni hao shi je “,“hell world”
printf(“%s”,str)-- ni
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
getchar(void) 也是从输入设备读取数据,读取到结束标志,就返回
例:
int c =1;
while(c =getchar()!=EOF)
{
print(”%c”,c); – 能读取多个含有空格的字符串
}

猜你喜欢

转载自blog.csdn.net/wutieliu/article/details/89643337
今日推荐