
C++ 无法打开头文件stdafx.h
d:\vc++6.0\microsoftvisualstudio\myprojects\ad\pont.cpp(1):fatalerrorC1083:Cannotopen...
d:\vc++6.0\microsoft visual studio\myprojects\ad\pont.cpp(1) : fatal error C1083: Cannot open include file: 'STDAFX.H': No such file or directory
执行 cl.exe 时出错
#include "stdafx.h"
enum lnstanceState{CLOSE=1,OPEN,MOUNT=4,UNMOUNT};//定义数据库的状态
void opt(lnstancestate state)
{
switch (state)
{
case CLOSE:
{
printf("打开数据库\n");
break;
}
case open:
{
printf("关闭数据库\n");
}
}
}
void main()
{
lnstanceState state=CLOSE;
opt(state);
} 展开
执行 cl.exe 时出错
#include "stdafx.h"
enum lnstanceState{CLOSE=1,OPEN,MOUNT=4,UNMOUNT};//定义数据库的状态
void opt(lnstancestate state)
{
switch (state)
{
case CLOSE:
{
printf("打开数据库\n");
break;
}
case open:
{
printf("关闭数据库\n");
}
}
}
void main()
{
lnstanceState state=CLOSE;
opt(state);
} 展开
展开全部
有的版本的VS没有stdafx.h这个头文件,相应的头文件是afx.h
你把
#include "stdafx.h"
改成
#include "afx.h"
应该就行了。
另外你的代码还有问题,完整修改如下:
#include "afx.h"
enum lnstanceState{CLOSE=1,OPEN,MOUNT=4,UNMOUNT};//定义数据库的状态
void opt(lnstanceState state) //这儿Instancestate
{
switch (state)
{
case CLOSE:
{
printf("打开数据库\n");
break;
}
case OPEN://open
{
printf("关闭数据库\n");
}
}
}
void main()
{
lnstanceState state=CLOSE;
opt(state);
}
结果:
追问
改完后错的更多了
d:\vc++6.0\microsoft visual studio\myprojects\ad\pont.cpp(3) : error C2065: 'lnstancestate' : undeclared identifier
d:\vc++6.0\microsoft visual studio\myprojects\ad\pont.cpp(3) : error C2146: syntax error : missing ')' before identifier 'state'
.......
追答
刚才我正在补充,你代码还有两个地方错误。
#include "afx.h"
enum lnstanceState{CLOSE=1,OPEN,MOUNT=4,UNMOUNT};//定义数据库的状态
void opt(lnstanceState state) //这儿Instancestate
{
switch (state)
{
case CLOSE:
{
printf("打开数据库\n");
break;
}
case OPEN://open
{
printf("关闭数据库\n");
}
}
}
void main()
{
lnstanceState state=CLOSE;
opt(state);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询