为什么这个程序调试不出来

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:13:03
#include<iostream>
#include<fstream>
using namespace std;
void p(ofstream &out)
{
out<<"I am ";
}
void p1(ofstream &out)
{
out<<"handsome!";
}
void main()
{
ofstream out("D:\\2.txt");
p(out);
p1(out);
}
e:\c++\msdev98\myprojects\aasd\asdffds.cpp(18) : fatal error C1010: unexpected end of file while looking for precompiled header directive
出现这样的错误????

我在我的机器上调试了,全部通过,也正常生成文件。
你试试文件头上添加一句:

#include "stdafx.h"

可能你建立新文件时建立的是C的文件,而不是C++的

你把你的这个代码复制到记事本里另存为 .cpp文件,再用VC编译就可以通了