C++问题,为什么在VC2008上通不过

来源:百度知道 编辑:UC知道 时间:2024/06/09 12:23:22
#include <iostream>
#include <string>
#include <cctype>

int main()
{
using namespace std;
cout<<"Enter words (q to quit):\n";
int vowel=0;
int consonant=0;
int other=0;
char n;
string name;
cin>>name;
while (name!="q")
{
n=tolower(name[0]);
if (isalpha(n))
{
if (n=='a' || n=='e'|| n=='i' || n=='o' || n=='u')

vowel++;
else
consonant++;
}
else
other++;
cin>>name;
}
cout<<vowel<<" words beginning with vowels \n";
cout<<consonant<<" words beginning with consonants \n";
cout<<other<<" others \n";
return 0;
}
iiiiiii.cpp

d:\my documents\visual studio 2008\projects\iiiiiii&#

在最开头写上 #include "stdafx.h"

必须是最开头

通的过,我试了,你的编译器可能有问题,要不就是工程建错了。

程序没有问题,可以在VC++2008中正常调试运行。

***************************************************

注意第二条,提示需要包含stdafx.h头文件