What the...

This is a discussion on What the... within the C++ Programming forums, part of the General Programming Boards category; Ok, this is a VERY simple program I'm trying to execute. However, at the linking stage I get an error: ...

  1. #1
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65

    What the...

    Ok, this is a VERY simple program I'm trying to execute. However, at the linking stage I get an error: LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

    Here's the code:
    Code:
    #include <fstream.h>
    
    
    void main() //the program starts here
    
    {
    
          ifstream OpenFile("txt.txt");
    
    
          char ch;
    
          while(!OpenFile.eof())
    
          {
    
                OpenFile.get(ch);
    
                cout << ch;
    
          }
    
          OpenFile.close();
    
    }
    Help?

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    My guess is your using MSVC++, and your building a console app, but didn't choose the project corresponding to console app. Thats why it wants WinMain instead of main.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    Aha, sorry about that... thanks.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Don't ever use void main( ). It's not legal C or C++. Always use int main( ).
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    fstream.h isn't legal C or C++ either. It should be <fstream>, and you'll probably need a "using namespace std;" in there, too.

Popular pages Recent additions subscribe to a feed

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