Thread: C++

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    C++

    Hey, I compiled the code, the one that I just asked about before (after i fixed it), and this window popped up called "Compiler and Linker Output" and it says... " C:\DEV-C_~1\Lib\\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16' ". That was after i pushed the "Compile and Run" option on the top of Dev-C++. the window said there were 0 errors, it had me press "continue" and that window was there...can someone explain to me what i am doing wrong?

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Show us some code!! We can 't help otherwise.

    Mr. C.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    4

    C++

    Sorry about that...here, i will post the question again and the code this time...
    Hey, I compiled the code, the one that I just asked about before (after i fixed it), and this window popped up called "Compiler and Linker Output" and it says... " C:\DEV-C_~1\Lib\\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16' ". That was after i pushed the "Compile and Run" option on the top of Dev-C++. the window said there were 0 errors, it had me press "continue" and that window was there...can someone explain to me what i am doing wrong? Here is the code...

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    
    bool accept3()
    {
    int tries = 1;
      while (tries < 4) {
         cout<<"Do you want to proceed (y or n)?\n";
         char answer = 0;
         cin >> answer;
    
         switch (answer) {
         case 'y':
            return true;
         case 'n':
            return false;
         default:
            cout<<"Sorry, I don't understand that.\n";
            tries = tries + 1;
         }
      }
      cout<<"I'll take that for a no.\n";
      return false;
      }
    Code tags added by Kermi3

  4. #4
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    In the future please use code tags when posting code. I added them for you this time. People are MUCH more likely to help you if you use them.

    Info on code tags may be found here:

    http://www.cprogramming.com/cboard/s...threadid=13473
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    cant see anything wrong with code you posted. Ill assume its just a snippet and you have a main() somewhere.
    The error you are getting is usually associated with trying to compile a console program as a windows program.
    Check your settings and be sure you are compiling for the right subsystem.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    When you complile your project in dev c++ you need to create a
    win32 console project. You also need to define main.


    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    bool accept3();
    
    bool accept3()
    {
      int tries = 1;
      while (tries < 4) {
         cout<<"Do you want to proceed (y or n)?\n";
         char answer = 0;
         cin >> answer;
    
         switch (answer) {
         case 'y':
            return true;
         case 'n':
            return false;
         default:
            cout<<"Sorry, I don't understand that.\n";
            tries = tries + 1;
         }
      }
      cout<<"I'll take that for a no.\n";
      return false;
      }
    
    int main()
    {
        accept3();
    
        return 0;
    }

Popular pages Recent additions subscribe to a feed