Results 1 to 4 of 4
  1. #1
    £X¢¤lĪbūr.'s Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    47
    Reputation
    10
    Thanks
    2
    My Mood
    Psychedelic

    Dos window auto-close

    I just started reading a book for C++ and have coded Hello World

    Code:
    #include <iostream.h>
    
    int main()
    {
         cout << "Hello World!\n";
         return 0;
    }
    So I compile it with Dev-C++ and run it, but my dos window flash closes upon executing the script.

    Windows Vista 32b (your standard PC)

    I can execute it through this process, but it is very lengthy and redundant:

    target of CMD.exe shortcut - C:\Windows\System32\cmd.exe /k "C:\dev-cpp\library\untitled1.exe"
    Last edited by £X¢¤lĪbūr.; 04-03-2011 at 01:17 AM.

  2. #2
    SERG's Avatar
    Join Date
    May 2010
    Gender
    female
    Posts
    41
    Reputation
    8
    Thanks
    8
    try this line of code before
    Code:
    return 0;
    Code:
    system("pause");
    i also want to mention since you are a beginner in C, this is an ok way to see what your doing, otherwise it's not safe to use on advance projects.

    https://stackoverflow.com/questions/1...hy-is-it-wrong
    Last edited by SERG; 04-03-2011 at 01:57 AM.

  3. #3
    Kiruku's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Aresden
    Posts
    80
    Reputation
    10
    Thanks
    203
    My Mood
    Relaxed
    or

    getchar();

    but u need to include: #include <stdio.h>

  4. #4
    Nathan's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    In a magical place
    Posts
    6,113
    Reputation
    394
    Thanks
    364
    Or you can just use:

    Code:
    cin.get()
    once or twice, and then it waits until you press enter.