Visual C++ Linking Problem: Unresolved External Symbol

This is a discussion on Visual C++ Linking Problem: Unresolved External Symbol within the C++ Programming forums, part of the General Programming Boards category; Okay. So I posted a couple of nights ago, asking how to reset the values from a file (here's the ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    4

    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:

    Code:
    /*
    Reset
    by
    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;
       Input_High_Scores.open("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; 
    Output_High_Scores.open ("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
    Location
    Singapore
    Posts
    21,630
    Try rebuilding the project, and while you are at it, change void main to int main.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    I think you made a Win32 project instead of a Win32 CONSOLE project.

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

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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
    Posts
    1

    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, 03:40 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04: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, 04:27 AM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21