C++ 错误LNK 1120和LNK 2001

C++ 错误LNK 1120和LNK 2001,c++,visual-c++,hyperlink,C++,Visual C++,Hyperlink,嘿,伙计们,我正在开发一个程序,它可以做很多简单的事情来向我的老师展示我已经学会了使用函数。我反复阅读了这个论坛,并查看了许多其他论坛,但似乎没有一个能解决我的问题。 由于下面的代码正在链接(我想),我在错误列表中得到了以下消息: 错误LNK1120:1个未解析的外部 错误LNK2001:未解析的外部符号\u mainCRTStartup 有人能帮我解决这个问题吗 这是我的密码 #include <iostream.h> #include <math.h> using

嘿,伙计们,我正在开发一个程序,它可以做很多简单的事情来向我的老师展示我已经学会了使用函数。我反复阅读了这个论坛,并查看了许多其他论坛,但似乎没有一个能解决我的问题。 由于下面的代码正在链接(我想),我在错误列表中得到了以下消息:

错误LNK1120:1个未解析的外部
错误LNK2001:未解析的外部符号
\u mainCRTStartup

有人能帮我解决这个问题吗

这是我的密码

#include <iostream.h>
#include <math.h>

using namespace std;

int a;
int b;
float c;
int d;

float p_theorem (int side_a, int side_b){
    return sqrtf((side_a * side_a)+(side_b * side_b));
}

float p_theorem_reverse (int side_c, int side_d){
    return sqrtf((side_c * side_c)-(side_d * side_d));
}

void game(int x){
    if (x < 5){
        cout<<"Your number is too low"<<endl<<"Please guess again: ";
        cin>>x;
    }
    else if (x > 5){
        cout<<"Your number is too big"<<endl<<"Please guess again: ";
        cin>>x
    }
    else (x == 5){
        cout<<"Good job, You guessed the number!"<<endl;
        system("PAUSE");
    }
}

void stuff(){
    cout<<"Developed by Ely Eastman"<<endl<<"Computer 35, T.H. Rogers Secondary     School, Houston, TX"<<endl;
    system("PAUSE");
}

int main(void)
{
    cout<<"Welcome to the Multi-Function Program"<<endl
        <<"Enter 1 for finding the hypotenuse of a right triangle"<<endl
        <<"Enter 2 for finding the leg of a right triangle"<<endl
        <<"Enter 3 for the Guessing Game Beta"<<endl
        <<"Enter 4 for Developer Information"<<endl;

    cin>>d
    if (d == 1){
        cout<<"Welcome to the Pythagorean Theorem Solver"<<endl
            <<"Please enter the length of one leg of the     triangle: ";
        cin>>a;
        cout<<"Please enter the length of the other leg of the triangle: ";
        cin>>b;
        c = p_theorem(a, b);
        cout<<"The length of the hypotenuse is "<<c<<endl;
        system("PAUSE");
    }
    else if (d == 2){
        cout<<"Welcome to the Reverse Pythagorean Theorem"<<endl
            <<"Please enter the length of the Hypotenuse: ";
        cin>>a;
        cout<<"Please enter the length of the known leg: ";
        cin>>b;
        c = p_theorem_reverse(a, b);
        cout<<"The length of the leg is: "<<g<<endl;
        system("PAUSE")
    }
    else if (d == 3){
        cout<<"Welcome to the Guessing Game Beta"<<endl
            <<"Please guess a number 1-10: ";
        cin<<a
            game(a);
    }
    else if (d == 4){
        stuff();
    }

    return 0;
}
#包括
#包括
使用名称空间std;
INTA;
int b;
浮点数c;
int d;
浮点p_定理(int边a,int边b){
返回sqrtf((side_a*side_a)+(side_b*side_b));
}
浮点数定理逆(整数侧c,整数侧d){
返回sqrtf((侧c*侧c)-(侧d*侧d));
}
虚空游戏(整数x){
if(x<5){

不能您有几十个缺少的“;”和一个缺少的if语句。而且游戏“g”的长度未定义。并且您的cin“>>”运算符在某些情况下是反向的

编辑:正如Neil在评论中指出的,您可能需要指定您正在创建一个控制台应用程序

工作?代码(请注意我更改了什么,而不仅仅是复制/粘贴,有些错误是非常基本的知识):

#包括
#包括
使用名称空间std;
INTA;
int b;
浮点数c;
int d;
浮点p_定理(int边a,int边b){
返回sqrtf((side_a*side_a)+(side_b*side_b));
}
浮点数定理逆(整数侧c,整数侧d){
返回sqrtf((侧c*侧c)-(侧d*侧d));
}
虚空游戏(整数x)
{
if(x<5)
{

cout假设您使用的是Visual Studio 2005,请转到项目的属性,在配置属性中打开链接器
子系统将是列表中的第一项。然后选择
Windows(/Subsystem:Windows)

检查项目设置并查看链接器选项是否已设置。如果已设置,请取消设置。

此程序如何进入链接阶段?
否则(x==5){
超链接
标记与你的程序有什么关系?你有几十个“;”和一个if语句。另外游戏“g”的长度没有定义。你可以“>>”在某些情况下,运算符是相反的…为了不那么歇斯底里,我怀疑您在真正想要创建Windows控制台项目时创建了Windows GUI项目。从逻辑上讲,如果提供的代码确实是@Ely使用的代码,那么问题是它不是作为项目的一部分生成的。如果它是生成的,那么会有be编译器错误,而不是链接器错误。我们需要确定包含此代码的文件是否实际作为项目的一部分进行编译。如果是,并且提供的代码不是文件中真正的代码,那么是的,我同意@Neil的说法,这可能是项目的错误配置。将
/SUBSYSTEM
设置为
WINDOWS
将使链接器查找
WinMain
wWinMain
。他显然想要
/SUBSYSTEM:CONSOLE
,因此链接器将查找
main
wmain
#include <iostream>
#include <math.h>

using namespace std;

int a;
int b;
float c;
int d;

float p_theorem (int side_a, int side_b){
    return sqrtf((side_a * side_a)+(side_b * side_b));
}

float p_theorem_reverse (int side_c, int side_d){
    return sqrtf((side_c * side_c)-(side_d * side_d));
}

void game(int x)
{
    if (x < 5)
    {
        cout<<"Your number is too low"<<endl<<"Please guess again: ";
        cin>>x;
    }
    else if (x > 5){
        cout<<"Your number is too big"<<endl<<"Please guess again: ";
        cin>>x;
    }
    else if (x == 5)
    {
        cout<<"Good job, You guessed the number!"<<endl;
        system("PAUSE");
    }
}

void stuff(){
    cout<<"Developed by Ely Eastman"<<endl<<"Computer 35, T.H. Rogers Secondary     School, Houston, TX"<<endl;
    system("PAUSE");
}

int main(void)
{
    cout<<"Welcome to the Multi-Function Program"<<endl
        <<"Enter 1 for finding the hypotenuse of a right triangle"<<endl
        <<"Enter 2 for finding the leg of a right triangle"<<endl
        <<"Enter 3 for the Guessing Game Beta"<<endl
        <<"Enter 4 for Developer Information"<<endl;

    cin>>d;
    if (d == 1){
        cout<<"Welcome to the Pythagorean Theorem Solver"<<endl
            <<"Please enter the length of one leg of the     triangle: ";
        cin>>a;
        cout<<"Please enter the length of the other leg of the triangle: ";
        cin>>b;
        c = p_theorem(a, b);
        cout<<"The length of the hypotenuse is "<<c<<endl;
        system("PAUSE");
    }
    else if (d == 2){
        cout<<"Welcome to the Reverse Pythagorean Theorem"<<endl
            <<"Please enter the length of the Hypotenuse: ";
        cin>>a;
        cout<<"Please enter the length of the known leg: ";
        cin>>b;
        c = p_theorem_reverse(a, b);
        cout<<"The length of the leg is: "<<c<<endl; // <- What is g?!!! I think you had a typo
        system("PAUSE");
    }
    else if (d == 3){
        cout<<"Welcome to the Guessing Game Beta"<<endl
            <<"Please guess a number 1-10: ";
        cin>>a;
            game(a);
    }
    else if (d == 4){
        stuff();
    }

    return 0;
}