C++switch语句
#include<iostream>
using namespace std;
int main()
{
char ch;
int kcnt=0,zcnt=0,hcnt=0;
while(cin>>ch)
switch (ch){
case' ':
++kcnt;
break;
case'\t':
++zcnt;
break;
case'\n':
++hcnt;
break;
default:
break;
}
cout << "Number of k: \t" << kcnt << '\n'
<< "Number of z: \t" << zcnt << '\n'
<< "Number of h: \t" << hcnt << '\n';
system("pause");
return 0;
}
求前辈帮我看一下该程序错在何处,在VS中运行结果都是零。