visual c++ 使用问题

来源:百度知道 编辑:UC知道 时间:2024/06/20 09:56:19
建立一个空工程后
代码为
#include<stdio.h>
int main()
{
printf("wo shi yi ge ren");
}

compile是出现
-------------------Configuration: woheni - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
woheni.cpp
e:\张振兴\vc\vc6\msdev98\myprojects\woheni\woheni.cpp(9) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.

woheni.exe - 1 error(s), 0 warning(s)

怎么使用?

你保存为.c后缀了吗?你用的C++编绎器。如果是你c++函数编的,则存为.cpp后缀。

用预编译了吧。要在开头加
#include "stdafx.h"
不然就会出现你的那个fatal error

或者你也可以在工程的属性里面把预编译头文件去掉

另外提醒一下main函数返回一个整数值

去掉main()前面的int,<stdio.h>改为"stdio.h"
#include"stdio.h"
main()
{
printf("wo shi yi ge ren");
}

int main() 定义的返回值为int型 但这里没有返回值
#include<stdio.h>
int main()
{
printf("wo shi yi ge ren");
return 0;
}

#include<stdio.h>
void main()
{
printf("wo shi yi ge ren");
}