标题:关于getche问题
取消只看楼主
罗彬
Rank: 1
等 级:新手上路
帖 子:141
专家分:0
注 册:2006-4-24
结帖率:100%
 问题点数:0 回复次数:1 
关于getche问题
请问一下为什么把getche变为getchar 或者cin.get()的时候就永远按回车都不能够把结果打出来,
如果变为getchar应该如何变程序,请各位高手指教.
#include<iostream.h>
#include<conio.h>
using namespace std;
main()
{
int char_count=0;
int word_count=0;
char ch;
cout<<"please enter a string:\n";
while((ch=getche())!='\r')
{
char_count++;
if (ch==' '||ch=='\t')
{word_count++;}

}
cout<<"\n This string contains"<<char_count
<<"character"<<endl;
cout<<"This string consists of"<<word_count+1
<<"word"<<endl;
return 0;
}
搜索更多相关主题的帖子: getche 
2007-03-14 22:48
罗彬
Rank: 1
等 级:新手上路
帖 子:141
专家分:0
注 册:2006-4-24
得分:0 

非常感谢,以后还请多指教


2007-03-15 12:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-124292-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.082376 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved