我的程序出错:
Linking...
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
===
下面是源程序:
// MyConsole.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <afx.h>//using namespace std;int main(int argc, char* argv[])
{
char* pBuffer = new char[0x1000];
         ......
return 0;
}

解决方案 »

  1.   

    改一下c runtime library 选项
    project -》 settings -》C/C++ -》Code Gerenation
    试试!
      

  2.   

    上面代码省略太多,重来
    #include "stdafx.h"
    #include <afx.h>//using namespace std;int main(int argc, char* argv[])
    {
    char* pBuffer = new char[0x1000];
    CFile file("mydoc.doc", 1);
              return 0;
    }
      

  3.   

    To: kof99th(小虫)
    我的是Debug Single-Threaded有什么问题么?
    怎么改?
      

  4.   

    int main(int argc, char* argv[])
    {
    char* pBuffer = (char *)malloc(0x1000);
    CFile file("mydoc.doc", 1);
              return 0;
    }
      

  5.   

    同意kof99th(小虫) 的看法,顶
      

  6.   

    #include "stdafx.h"
    #include <afx.h>上述包含文件中去掉 #include <afx.h>
      

  7.   

    你新建一个win32 console工程 然后把这段代码加进去 就对了
    运行裤的问题
      

  8.   

    To:icr_mio(兄弟姐妹们,冲啊!) 
    换成char* pBuffer = (char *)malloc(0x1000);
    出现如下错误:
    Linking...
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/MyConsole.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.
      

  9.   

    char* pBuffer = (char *) (new char[0x1000]);
    可以么?
      

  10.   

    To: BinaryTreeEx(狂徒) 
    一样的错误
    Linking...
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCD.lib(new.obj)
      

  11.   

    在Project->Setting->General->Microsoft Foundation Classes中选择使用MFC
      

  12.   

    应该是项目设置的问题,楼主是在WINCE系统下的吗?
    把你的运行环境描述一下
      

  13.   

    删除Debug,重新编译一下,试试...或者是头文件包含重复?
      

  14.   

    To:icr_mio(兄弟姐妹们,冲啊!) 
    在Project->Setting->General->Microsoft Foundation Classes中选择使用MFC
    ========
    正解