标题:C++中编译通过,运行错误问题
只看楼主
台湾槟榔
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-7-16
结帖率:0
已结贴  问题点数:10 回复次数:4 
C++中编译通过,运行错误问题
我是一名编程的初学者,在学习中遇到了一些问题,希望大家帮我解决!
#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 时出错.
搜索更多相关主题的帖子: 运行 编译 
2009-07-16 14:02
莫云今次
Rank: 3Rank: 3
来 自:浙江
等 级:论坛游侠
帖 子:385
专家分:166
注 册:2009-3-18
得分:2 
估计你工程建错了
2009-07-16 15:05
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
得分:2 
链接错误.把子系统改成console

天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2009-07-16 18:28
nikeyibufu
Rank: 1
等 级:新手上路
帖 子:7
专家分:8
注 册:2009-7-24
得分:2 
#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");
}这个看看
改了
2009-07-27 12:45
明次
Rank: 5Rank: 5
来 自:China
等 级:职业侠客
帖 子:166
专家分:303
注 册:2009-1-11
得分:2 
LZ用的是什么编译器?我这编译通过 运行也没有错误啊~

、明次℡!           QQ:604622530
2009-07-27 12:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-279632-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.094725 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved