Thread: printf appears so fast

  1. #1
    Registered User slyer4ever's Avatar
    Join Date
    Oct 2013
    Posts
    41

    printf appears so fast

    Hii everyone
    i've a little problem when i compile
    Code:
    int main()
    {
    printf("Hello world!");
    return 0;
    }
    i can't see the" hello world "also when i have a printf in the end of the code i can't see it because it appears so fast that i can't see it
    i use getch() for blocking the display but it's not practical to use it every time i need to display something

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    126
    exit(100);

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    What is the purpose of doing exit(100)? This will send the return code back to the operating system, but it does not guarantee any particular behaviour such as pausing for a keypress.

  5. #5
    Registered User
    Join Date
    Nov 2013
    Location
    Silicon Valley, CA
    Posts
    7
    OMG, the best way to do this is by putting the code " system("PAUSE"); " above return 0; like this.
    Code:
    int main()
    {
        printf("Hello world!");
    
        system("PAUSE");
        return 0;
    }
    Here's your solution.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > OMG, the best way to do this is by putting the code " system("PAUSE"); " above return 0; like this.
    Someone else who should read the FAQ.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by James Moon View Post
    OMG, the best way to do this is by putting the code " system("PAUSE"); " above return 0; like this.
    As Salem said, you need to read the FAQ. system("PAUSE") is a VERY poor solution to the problem, since it isn't guaranteed to work.

    It's posts like yours (giving a solution that doesn't really work) that give me a hankering for a new feature in the forum software ..... a "Dislike" button.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Why not just use

    Code:
    getchar();
    Simple. Or if you use a Makefile or something similar to run your program, then go ahead and use "pause" or some other system command after running your program, with the understanding that this is just for your own purposes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String appears to change on its own
    By jim-_- in forum C Programming
    Replies: 7
    Last Post: 01-22-2011, 10:59 PM
  2. Window appears in a flash! But also disappears as fast...
    By legit in forum Windows Programming
    Replies: 8
    Last Post: 07-04-2009, 10:30 AM
  3. Strtoking where a delimiter appears after itself.
    By Evenstevens in forum C Programming
    Replies: 8
    Last Post: 05-04-2009, 08:16 PM
  4. EOF appears not on end of file?!
    By v01d in forum C Programming
    Replies: 12
    Last Post: 08-31-2007, 12:13 AM
  5. the console always appears......
    By gandalf_bar in forum C++ Programming
    Replies: 7
    Last Post: 01-10-2005, 11:16 AM