Thread: devc++seeing results

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    25

    devc++seeing results

    When I compile and run a program in devc++ the results screen flashes and goes away. Only way I have found to see results is to add an scanf and then the screen stay up to veiw. Any one know what I can do.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    34

    Dev-C++

    Yes.

    Newer release:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;

    int main()
    {
    cout<<"Hello world!\n";
    system("PAUSE");
    return 0;
    }

    Dev-C++ 4.1:

    #include <stdlib.h>
    #include <stdio.h>

    int main()
    {
    printf("Hello world!\n");
    system(PAUSE");
    return 0:
    }

    Hope this helps.

  3. #3
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    You can put at the end of your program:
    Code:
    system("pause");
    The system() function is declared in stdlib.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    thks for the info I appreacite it very much.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Vber
    You can put at the end of your program:
    Code:
    system("pause");
    The system() function is declared in stdlib.
    I will never understand why people feel the need to use this. Why not use:

    getchar( );

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    Quzah, Sometimes getchar() alone don't works for me, he don't pause the program, system("pause"); works always.

    Why, have something wrong with this function?

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Vber
    Why, have something wrong with this function?
    It's generally considered a good idea to avoid system calls when you can. The reason getchar() won't work for you is that there's probably something left over in your input stream before the check.
    Code:
    void mypause( void )
    {
        while( getchar( ) != '\n' );
        printf("Press enter to exit.");
        getchar( );
    }
    That should work. Either one is fine. You can use system() if you like. Most people tend to avoid it.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Incorrect results from fmod()?
    By karlthetruth in forum C Programming
    Replies: 4
    Last Post: 04-11-2008, 09:12 AM
  2. Results of March Monthly Contest
    By PJYelton in forum Contests Board
    Replies: 23
    Last Post: 04-17-2005, 09:46 AM
  3. 72hour GDC Results
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-05-2004, 11:46 PM
  4. Same seed for srand yields different results
    By codegirl in forum C++ Programming
    Replies: 3
    Last Post: 06-23-2003, 02:39 PM
  5. show all compiler results?
    By bluehead in forum C++ Programming
    Replies: 2
    Last Post: 08-20-2002, 10:57 PM