#include<string>int acnt=0,ecnt=0,icnt=0,ocnt=0,ucnt=0,cnt=0;string buf;while(cin>>buf)
{
for(ix=0;ix<buf.size();++ix)
{
switch(buf[ix])
{ case 'a':++acnt;++cnt;break;
case 'e':++ecnt;++cnt;break;
case 'i':++icnt;++cnt;break;
case 'o':++ocnt;++cnt;break;
case 'u':++ucnt;++cnt;break;
default:++cnt;break;
}
}
}
cout<<"A: "<<acnt<<endl
<<"E: "<<ecnt<<endl
<<"I: "<<icnt<<endl
<<"O: "<<ocnt<<endl
<<"U: "<<ucnt<<endl;
return 0;
}为何在VC6中无法通过?--------------------Configuration: temp - Win32 Debug--------------------
Compiling...
temp.cpp
C:\temp.cpp(5) : error C2146: syntax error : missing ';' before identifier 'buf'
C:\temp.cpp(5) : error C2501: 'string' : missing storage-class or type specifiers
C:\temp.cpp(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.temp.exe - 3 error(s), 0 warning(s)以上是错误信息,请帮忙!
{
for(ix=0;ix<buf.size();++ix)
{
switch(buf[ix])
{ case 'a':++acnt;++cnt;break;
case 'e':++ecnt;++cnt;break;
case 'i':++icnt;++cnt;break;
case 'o':++ocnt;++cnt;break;
case 'u':++ucnt;++cnt;break;
default:++cnt;break;
}
}
}
cout<<"A: "<<acnt<<endl
<<"E: "<<ecnt<<endl
<<"I: "<<icnt<<endl
<<"O: "<<ocnt<<endl
<<"U: "<<ucnt<<endl;
return 0;
}为何在VC6中无法通过?--------------------Configuration: temp - Win32 Debug--------------------
Compiling...
temp.cpp
C:\temp.cpp(5) : error C2146: syntax error : missing ';' before identifier 'buf'
C:\temp.cpp(5) : error C2501: 'string' : missing storage-class or type specifiers
C:\temp.cpp(5) : fatal error C1004: unexpected end of file found
Error executing cl.exe.temp.exe - 3 error(s), 0 warning(s)以上是错误信息,请帮忙!
#include<string>
using namespace std;
试一下吧
#include <string>
using namespace std;