找不到stdfax.h
#include <stdafx.h>
#include <iostream>
#include <String>
using namespace std;
int main()
{
int errors = 0;
string str( "a very long literal string" );
for ( int ix = 0; ix < 1000000; ++ix )
{
int len = str.size();
string str2 = str;
if ( str != str2 )
++errors;
}
cout << "string class: "
<< errors << " errors occurred.\n";
return 0;
}
直接用文件--新建--C++ Source File,是不行的,有这样的错:D:\C++练习\Cpp1.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory