#include "stdafx"
#include "iostream"
#include "string"
using namespace std;int main(int argc, char* argv[])
{string str="sdfsdfsdfds";
return 0;
}
编译时为什么出错啊
fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

解决方案 »

  1.   

    #include "stdafx.h"//这里错了
    #include "iostream"
    #include "string"
    using namespace std;int main(int argc, char* argv[])
    {string str="sdfsdfsdfds";
    return 0;
    }
    编译时为什么出错啊
    fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.
      

  2.   

    如楼上所说,第一行出错了。为什么其它的两个include 可以不要加.h呢?因为本来就有iostream和string两个文件在(可以在include 目录中找到)。stdafx.h文件跟它们完全不是一回事。另外建议下面改成这样:
    #include <iostream>
    #include <string>