VC++ 错误及解决方案录

来源:互联网 发布:女朋友下面的味道知乎 编辑:程序博客网 时间:2024/06/07 10:31

VC++ 错误及解决方案录

 

 

error LNK2001: unresolved external symbol _main解决办法(zz)
error LNK2001: unresolved external symbol _main解决办法

在编译VC++6.0是,出现fatal error C1010: unexpected end of file while looking for precompiled header directive
的错误.

解决方法:

1、如果发生错误的文件是由其他的C代码文件添加进入当前工程而引起的,则Alt+F7进入当前工程的 Settings,选择C/C++选项卡,从Category组合框中选中Precompiled Headers,选择Not Using Precompiled headers。确定。

2、在文件开头添加:
#include "stdafx.h"

对预编译头文件说明如下:  
   
所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。  
   
预编译头文件通过编译stdafx.cpp生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。  
   
编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include   "stdafx.h"前的代码都是预编译的,它跳过#include   "stdafx.   h"指令,使用projectname.pch编译这条指令之后的所有代码。  
   
因此,所有的CPP实现文件第一条语句都是:#include   "stdafx.h"。   

 

 

 

 

 

 

 

 

 

2008-10-17:

 

error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class ostream_withassign' (or there is no acceptable conversion)

 

解决办法可能是.h和namespce std;冲突,选后者;

 

error C2079: 'file' uses undefined class 'std::basic_fstream<_Elem,_Traits>'

The fstream class is defined in the fstream header. Try adding a #include <fstream>.

http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/0b6174ad-bcfd-4863-b83f-bfd64a5f3620/

 

ios::app 与 iso:ate 的区别

 http://topic.csdn.net/t/20050103/21/3696236.html

fstream  能否作为函数参数传递进去? (很简单,fstream对象本身不可以拷贝,但用引用可以将其做为参数传递给函数)

http://topic.csdn.net/t/20030215/11/1430571.html

C++ file and directory 删除,移动,目录浏览对话框,找某目录下的所有文件(包括子目录)

C++ Programmer's Cookbook

http://www.cppblog.com/mzty/archive/2006/01/12/2683.html

C++ Primer中文版(第4版) HTML 版

http://www.17xie.com/book-35806982.html

 

C++实现加减乘除

http://www.cppblog.com/jb8164/archive/2008/01/02/40211.html

 

rand() & srand() 清爽版:

http://zhidao.baidu.com/question/4856192.html

srand(time(0)); 的目的是使的每次产生的随机数不同。如下:
#include "stdafx.h"
#include "time.h"
#include "stdlib.h"
#include "iostream.h"
int main(int argc, char* argv[])
{
for(int i=0;i<100;i++)
cout<<rand()<<'/t'<<endl;
return 0;
}
这里没有调用 srand 函数,你两次运行程序看一下所产生的数是不是一样,然后将 srand(time(0))加入到 for 的上面就不一样了。
srand(time(0));
for(int i=0;i<100;i++)
cout<<rand()<<'/t'<<endl;
return 0;

C++文件读写操作(下面这篇讲得清新易懂):

http://waicpp.blog.sohu.com/26485974.html

VS2005生成帮助文档

http://blog.csdn.net/dreambroken/archive/2007/07/26/1709594.aspx

原创粉丝点击