Search code examples
c++unresolved-external

LNK2019: unresolved external symbol C++ converting Fahrenheit to Celcius


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

int main()
{
// declare variables
    string name; 
    float fahrenheit, celcius;
//display greeting
    cout << "Please enter your first name: ";
    cin >> name;
//ask for fahrenheit
    cout << "Enter a temperature in Fahrenheit degrees please: ";
    cin >> fahrenheit;
//write equation
    celcius = 5.0f/9.0f * (fahrenheit - 32.0f);
//display result
    cout << "Hi " << name << endl << endl;
    cout << "The equivalent to " << fahrenheit << "degrees Fahrenheit is" << celcius << "degrees Celcius" << endl << endl;

return 0;
}

I'm not sure what exactly is incorrect I have checked so many times and played with the code to get rid of the errors to no avail. Any help is appreciated.


Solution

  • as an explanation for you

    the code you have typed is perfectly correct. It compiles cleanly. But the way things have been setup to complete the process to make a running app ('linking') is failing.

    The linker is expecting to find an entry point called _WinMain (hence the error message). This is because when you created the project you said it was a windows app - which its not. YOu need to ask you prof

    Also - when asking "why do I get this error?" always include the error in the question