Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
847 views
in Technique[技术] by (71.8m points)

visual c++ - C++ LNK1120 Fatal Error: 1 unresolved externals

I'm trying to compile this code using MS Visual Studio Professional 2010 and it's giving me a build error LNK1120 Fatal Error: 1 unresolved externals. Here's the code...

// 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;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The only possibility is missing WinMain (or its variant). To resolve goto Project Settings, Linker -> System, and select /SUBSYSTEM:CONSOLE.

It that's not the problem, kindly paste entire error message.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...