Thread: Check this out !

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    This might throw up some bugs too. Compilers often add code before and after the entry point (this is why you need to call exit() - the compiler usually provides that and passes the return of main to it). It's possible that some initialisation code could be missed and this could possible cause some problems with various libraries you are using or even maybe lead to a crash. Who knows - it's not standard so anything's feasible

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    Yes, I see it more as some sort of a bug in ld.exe that it allows it to go thru with just a warning. You should not really be able to do this, it's sort of like the public static main in a Java app.

    Here is a better way of writing this...

    Code:
    #include <iostream>
    
    class Application
    {
        char *s;
    public:
        Application(): s("Hello !")
        {
            std::cout << s;
            std::getchar();
            std::exit(0);
        }
    }
    WinMain;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. how to check input is decimal or not?
    By kalamram in forum C Programming
    Replies: 3
    Last Post: 08-31-2007, 07:07 PM
  3. Please check this loop
    By Daesom in forum C++ Programming
    Replies: 13
    Last Post: 11-02-2006, 01:52 AM
  4. A way to check for Win98 or WinXP
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 10-31-2002, 11:06 AM
  5. how to check for end of line in a text file
    By anooj123 in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2002, 11:21 PM