Exec newbie question

This is a discussion on Exec newbie question within the C++ Programming forums, part of the General Programming Boards category; Ok I made a small code, just to give some simple output, but when it runs it closes the window ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    11

    Exec newbie question

    Ok I made a small code, just to give some simple output, but when it runs it closes the window when it finishes. I know this must just be a problem with my DOS window automatically closing when finished. Anyone know how to make it stay open once it's finished?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    Just Read This FAQ
    Woop?

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    58
    if it is in dos and u have conio.h (just find out) at the end of ur program before the final "}" or the "return" statement of main use getch(); that should solve ur problem.


    i couldnt imagine an "exec" and a newbie together.
    Last edited by gooddevil; 05-30-2004 at 11:45 AM.
    even a fish would not have been in danger had it kept its mouth shut.

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    22
    Trace and Debug ! Determine where you have gone wrong!

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    11
    No there is no problem with the code, it's a windows problem and I know that there is a permanent solution out there somewhere how to disable automatically closing. Any ideas?

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    11
    Quote Originally Posted by gooddevil
    i couldnt imagine an "exec" and a newbie together.
    didn't know quite what to call it, exec stands for execute :P

  7. #7
    Registered User
    Join Date
    Apr 2004
    Posts
    58
    can u give some more detail, which compiler, what code etc etc.....
    even a fish would not have been in danger had it kept its mouth shut.

  8. #8
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I know that there is a permanent solution out there somewhere how to disable automatically closing.
    Possibly, if you run it from a shortcut. Otherwise, I doubt it unless you want to do some mucking around in the registry, in which case there's still no guarantee. Try folder options and stuff like that. But unless you're running the program from a DOS command prompt (i.e. go Run and type "command"), you're probably going to have a hard time doing it without building it into your code.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  9. #9
    Useless Apprentice ryan_germain's Avatar
    Join Date
    Jun 2004
    Posts
    76

    Read the reply

    it has nothing to do with the dosbox....just read what prog_bman said! Just add the code buddy!

  10. #10
    Registered User
    Join Date
    May 2004
    Posts
    11
    I know I can just add the code it is what I have been doing. But I know it's a windows thing and I'm also pretty sure theres a permanent solution. I'm using Bloodshed Dev C++ compiler, and the code does not apply to the question seeing as it closes after reaching the end of any code.

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh, you mean stay open and allow you to type DOS commands in? I doubt it unless (again) you run it from a DOS prompt to begin with, or spawn a new DOS console using CreateProcess() or something at the end of your code, which still won't do exactly what you want.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #12
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    2. When executing my dos program, it closes automatically. How I can change this ?

    You can use an input function at the end of you source, like the following example :
    Code:
    #include <stdlib.h>
    int main()
    {
    system(“PAUSE”);
    return 0;
    }
    Straight from the Dev-C++ website: http://www.bloodshed.net/faq.html#2
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  13. #13
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>You can use an input function at the end of you source, like the following example
    Does that allow the user to input DOS commands? If not, how is it unique from any other solution posted above?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  14. #14
    Registered User
    Join Date
    Jun 2004
    Posts
    24
    Add the following line into your code before "return 0;"

    cin.ignore();

  15. #15
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Add the following line into your code before "return 0;"

    cin.ignore();
    And I hereby quote myself from 1 post above:
    Quote Originally Posted by Hunter2
    how is it unique from any other solution posted above?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  3. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 05:45 PM
  4. a stupid question from a newbie
    By newcomer in forum C++ Programming
    Replies: 4
    Last Post: 01-11-2003, 03:38 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21