C ++ LNK1120致命错误:1个未解析的外部

时间:2012-02-27 00:10:38

标签: c++ visual-c++

我正在尝试使用MS Visual Studio Professional 2010编译此代码,它给我一个构建错误LNK1120致命错误:1个未解析的外部。 这是代码......

// Program Typos prints three integer numbers, sums the numbers, calculates
// the average, and prints the sum and the average of the three numbers.

#include <iostream>
#include <iomanip>
using namespace std;

const int ONE = 5;
const int TWO = 6;
const int THREE = 7;

int main ()
{
    int sum;
    float average;


    cout  << fixed  << showpoint;

    cout << setw(5) << ONE  << TWO  << THREE << endl;
    sum = ONE + TWO + THREE;
    average = sum / 3;
    cout  << " The sum is "  << sum  << " and the average is " \
      << average  <<endl;
    return 0;
}

1 个答案:

答案 0 :(得分:0)

唯一的可能性是缺少WinMain(或其变体)。要解决goto项目设置,链接器 - &gt;系统,然后选择/SUBSYSTEM:CONSOLE

这不是问题,请粘贴整个错误消息。