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

两个bug谁帮着看看

lxy8881 发布于 2008-09-12 23:27, 645 次点击
[size=5][bo]LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/传值和引用的一个问题.exe : fatal error LNK1120: 1 unresolved externals[/bo]
[/size]




这两个bug是在编写下面的这个程序时出现的,大哥们帮我看看是什么原因:
#include<iostream.h>
int* ret(int i)
{
    int *p;
    p=&i;
    return p;
};
void main()
{
    int *h;
    int i=10;
    h=&i;
    cout<<*h<<"\t"<<h<<endl;
    int *p;
    p= ret(i);
    cout<<*p<<endl;
    cout<<p<<endl;
}
4 回复
#2
PeterOffice2008-09-13 14:06
缺少链接库.->project->setting里设置
缺少链接库.->project->setting里设置
#3
blueboy820062008-09-13 15:03
代码没问题,编译器的问题...
#4
newyj2008-09-13 19:59
好象不能返回函数局部变量吧
不知道 对不对
#5
liotta2008-09-13 20:36
回复 1# lxy8881 的帖子
int* ret(int i)
{
    int *p;
    p=&i;
    return p;
};

int i是个临时变量 ,ret()调用后就不存在了,你还后面(cout<<*p<<endl;)还*p做什么(没意义嘛)?
不知你这个程序是表现什么的?

在linux下倒也能运行!

[[it] 本帖最后由 liotta 于 2008-9-13 20:38 编辑 [/it]]
1