关于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;
}