Thread: Visual C++ Linking Problem: Unresolved External Symbol

  1. #1
    Registered User
    Join Date
    Nov 2010

    Visual C++ Linking Problem: Unresolved External Symbol

    Okay. So I posted a couple of nights ago, asking how to reset the values from a file (here's the link: Please Help?). I think I'm on the right track, but I'm not sure. Here's the code:

    Your Name
    Used to reset the high scores from the High_Score.txt file
    // Include the libraries
    #include <iostream>
    #include <string>
    #include <fstream>
    // Use the standard namespace
    using namespace std;
    void main ( )
       //Declare local variables 
       int High_Score[5]; 
       string High_Score_Name[5]; 
       char User_Input;
       // Input the high scores from a file
       ifstream Input_High_Scores;"High_Scores.txt");
       for (int i = 0; i < 5; i++)
    		Input_High_Scores >> High_Score[i];
    		Input_High_Scores >> High_Score_Name[i];
       Input_High_Scores.close ();
    // Give output to user
    cout << "Would you like to reset the high scores? Y for yes, N for no." << endl;
    cin >> User_Input;
     // Output the high scores to a file 
     ofstream Output_High_Scores; ("High_Scores.txt"); 
    if (User_Input == 'Y' || 'y') 
    	High_Score[0] = 25000; 
    	   High_Score[1] = 12000; 
    	   High_Score[2] = 7500; 
    	   High_Score[3] = 4000; 
    	   High_Score[4] = 2000; 
    	   High_Score_Name[0] = "Gwyneth"; 
    	   High_Score_Name[1] = "Adam"; 
    	   High_Score_Name[2] = "Nastasia"; 
    	   High_Score_Name[3] = "Nicolas"; 
    	   High_Score_Name[4] = "Dani";
       Output_High_Scores.close ( ); 
          for (int i = 0; i < 5; i++)
    	   cout << High_Score[i] << " " << High_Score_Name[i] << endl;
       system ("PAUSE");
    However, when I try and debug, I get an error:
    MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

    How can I fix this, and am I on the right track to making it work?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Try rebuilding the project, and while you are at it, change void main to int main.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Join Date
    Dec 2007
    I think you made a Win32 project instead of a Win32 CONSOLE project.

  4. #4
    Registered User
    Join Date
    Nov 2010
    I got the same error after trying to rebuild it, and after switching it to an int main instead of void main.

  5. #5
    Join Date
    Oct 2007
    Inside my computer
    Goto project properties -> linker -> system -> set subsystem to "console".
    In the future, create a win32 console project.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Nov 2010

    Giant Campus?

    Neoanderson would you happen to be in a giant campus class? i was having the same problem exactly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overloaded Operator Causes Unresolved External Symbol
    By mikeman118 in forum C++ Programming
    Replies: 11
    Last Post: 03-03-2008, 04:40 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM