• 0

Unresolve Externals error in C++


Question

Got a problem... I'm trying to do a little test of the .length() function in C++. The compile and code both look good... I think. But whenever I try to run the program I get this error.

--------------------Configuration: A2 Part 1 - Win32 Debug--------------------

Compiling...

splitter.cpp

Linking...

LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

Debug/A2 Part 1.exe : fatal error LNK1120: 1 unresolved externals

Error executing link.exe.

A2 Part 1.exe - 2 error(s), 0 warning(s)

My program current reads like this;

#include <iostream> // for cin, cout

#include <iomanip> // for setw(), setprecision()

#include <string>

using namespace std;

int main()

{

string phrase;

// string::size_type len;

cout << "Enter 5 words ending each word with a //, including the last on. Press enter when you have finshed.";

cin >> phrase;

cout <<endl <<endl;

cout <<phrase.length() <<endl;

return 0;

}

All I want is to see the number of characters there are in the phrase I want to enter.

Any help would be appreciated.

Thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Well, the error message is fairly self-explanatory. The compiler is expecting that you're creating a Windows application and is looking for the standard entry point (WinMain), but you're actually writing a DOS command-line application, and using the DOS entry point (main).

Since it appears you're using Visual Studio, you won't be able to create a DOS app, so you need to rewrite this to be a Win32 console app.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.