首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

linux c解决方法

2013-03-26 
linuxc#includestdio.hint main(){int count 0int i 0char ch[10]printf(please input:\n)sca

linux c
#include<stdio.h>
int main()
{
int count = 0;
int i = 0;
char ch[10];

printf("please input:\n");
scanf("%s",ch);

while(ch[i] != '\0' )
{
if(ch[i] == ' ')
{count++;
}
i++;
}
printf("\n the counts is %d\n",count);
return 0;
}我想知道为什么这个程序算不出空格的个数(在liunx下)

[解决办法]
scanf("%s",ch); 这个函数遇空格就停止读了。百度出来看看

热点排行