非常棘手的问题,stdafx.h不存在的问题。

luo_raul 2009-07-29 11:30:57

关于#include "stdafx.h"的问题
调试时总是出现这样的错误(stdafx.h不存在),怎么解决?'stdafx.h'文件在哪?谢谢!
我的工程是:win32 console application 在CPP文件中的代码如下:这个是操作系统的进程调度的代码,是上网找来的。
#include "stdafx.h"
#include"iostream.h"
const m=100;
struct node{
int data1;//到达时间;
int data2;//完成时间;
int length;//作业长度;
}a[m];
int i=0;
void push(int d1,int d2,int l)
{

a.data1=d1;
a.data2=d2;
a.length=l;
i++;
}
int pop(int j)
{
int y;
if(j>=m)
return 0;
y=a[j].data2-a[j].data1;
a[j+1].data2+=a[j].data2;
cout< return 1;
}
void f()
{
int j,k;node t;
for(j=0;j for(k=0;k if(a[k].length>a[k+1].length)
{
t=a[k];
a[k]=a[k+1];
a[k+1]=t;
}
}
void main()
{
int x,y,d1,d2,l1,k;
cout<<"输入进程个数:";
cin>>k;
if(k for(x=0;x {
cin>>d1>>d2>>l1;
push(d1,d2,l1);
}
f();
for(y=0;y pop(y);
}

C:\Program Files\Microsoft Visual Studio\MyProjects\43454545\3.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory


我自己也去网上找了个stdafx.h放在VC98的include目录下,可是编译的时候另一个问题又出现了
c:\program files\microsoft visual studio\vc98\include\wspiapi.h(45) : error C2265: '<Unknown>' : reference to a zero-sized array is illegal
执行 cl.exe 时出错.
在线等,大家帮帮我。


...全文
3819 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
楼主,用VS的?没啥事留着预编译头选项没关系。

你是不是建立的一个完整的工程先?
重建一个工程看下,代码拷贝进去。
kojie_chen 2009-07-29
  • 打赏
  • 举报
回复
删了吧,要不就直接
#include stdio.h
stdlib.h
f22fbi 2009-07-29
  • 打赏
  • 举报
回复
同意1L
删了
whsfer 2009-07-29
  • 打赏
  • 举报
回复
本人认为楼主首先要看一下你所创建的工程里面有没有这个头文件,如果没有可以添加一个;另一种方法就是直接把#include "stdafx.h"去掉,感觉不会有什么影响~~
Jagen在路上 2009-07-29
  • 打赏
  • 举报
回复
这个是预编译头,楼主可以不用的,直接删除掉。
szqh97 2009-07-29
  • 打赏
  • 举报
回复
直接删了#include "stdafx.h"
就可以来的
RickXing 2009-07-29
  • 打赏
  • 举报
回复
#include "stdafx.h" 该头文件是VS下默认的预编译头文件,
在VS2005/2008工程中的属性>配置属性>C/C++>预编译头>通过文件创建/使用PCH
中可以配置头文件的文件名

一般程序员为了,使自己的CPP文件不做任何改动就可以在其他平台运行,往往会把这个
stdafx.h改成自己喜欢的文件名。因为把stdafx.h放在linux下总觉得不合适

修改方法是:VS2005/2008工程中的属性>配置属性>C/C++>预编译头>通过文件创建/使用PCH 改动为ABC.h后 (ABC.h 包含 stdafx.h )
并创建对因的ABC.cpp(只需包含ABC.h),并将ABC.cpp的属性>配置属性>C/C++>预编译头>创建/使用预编译头 设置为创建预编译头(/YC) 即可
rsp19801226 2009-07-29
  • 打赏
  • 举报
回复
或者改成#include <stdafx.h>试试
glorywu 2009-07-29
  • 打赏
  • 举报
回复
1. 可以直接删。
2. 没有的话,你可以加一个。
sea_spray 2009-07-29
  • 打赏
  • 举报
回复
支持5楼

33,323

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧