注册 登录
编程论坛 C++教室

C++中编译通过,运行错误问题

台湾槟榔 发布于 2009-07-16 14:02, 618 次点击
我是一名编程的初学者,在学习中遇到了一些问题,希望大家帮我解决!
#include <iostream.h>
void main()
{
    enum color {red,yellow,white=8,blue,black=-3,green=97};
    color i=yellow;
    int mycolor=red;
    char ch=green;
    cout << i << endl << mycolor << endl << ch << endl;
    cout << (yellow<black?yellow:black) << endl;
    cout << (white+black) << endl << ch << endl;
}
这段代码是正确的,编译成功,运行出错!
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Test1_0.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
4 回复
#2
莫云今次2009-07-16 15:05
估计你工程建错了
#3
随心2009-07-16 18:28
链接错误.把子系统改成console
#4
nikeyibufu2009-07-27 12:45
#include <iostream>
using namespace std;
int main()
{
    enum color {red,yellow,white=8,blue,black=-3,green=97};
    color i=yellow;
    int mycolor=red;
    char ch=green;
    cout << i << endl << mycolor << endl << ch << endl;
    cout << (yellow<black?yellow:black) << endl;
    cout << (white+black) << endl << ch << endl;
system("pause");
}这个看看
改了
#5
明次2009-07-27 12:56
LZ用的是什么编译器?我这编译通过 运行也没有错误啊~
1