hi all;
it's the first time i use Dev C++ and i liked it after a lot of stupid errors while useing MV Studio... and for the first time i had tried to test it and i wrote the following code:
No errors and also no warnings, but when built it then pressed on "RUN" the excution .exe appeares to me... and entered 1 2 3 4 5 then enter
but the .exe closed itself without no results.
It is normal behaviour in Windows (and probably all other GUI environments) that when a process terminates, its window is closed. Your program is not magically any different. If you did not write code to prevent your application from terminating, then it did exactly what you coded it to do.
This 'problem' is so common it is dealt with in the "PLEASE READ BEFORE POSTING A QUESTION*" thread in this very forum!
Some environments (such as VC++) execute IDE launched processes as a child process of another so that the program does not own the window so it does not close. Dev-C++ does not do that. Don't ask me why.
Another solution is to run the code in the debugger, with a breakpoint at the end of main(). But to be honest, if you get the debugger in Dev-C++ to work reliably, you are a better man than I. To be honest, you are going backward if you abandoned VC++ in favour of Dev-C++.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks a lot Clifford for your careness, but the point u didn't get is that any program u ever run must give you your result before closing the command window showing a sentense asking you to press any key to continue and run out from your program, but my one is running out before showing any results and that what am asking about.
Thanks again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can assure you that I "got the point" and you are wrong. If you do not write your program to wait for a key press it should terminate.
The only reason that you get that help in VC++ is because your program is run within another program that does that for you.
> any program u ever run must give you your result before closing
Well that is not true, not all programs must necessarily have visible console output. However in your case the output was displayed, and your program terminated, and its window closed. The results were displayed for so short a time you did not see them.
> showing a sentense asking you to press any key to continue
Only if you either write that code to run from within an environment that does that for you. This is not normal behaviour and would be undesirable if say a program was to be executed as part of a batch process.
I suggest that you take any program that you wrote in VC++ where you expect the "press any key" prompt and run it directly from Explorer. You will find that it behaves in exactly the same way as running a program from within Dev-C++. The wait prompt is provided by the IDE not the compiler - it is not part of the application.
There was a time when this question came up two or three times a week or more. That is why the solution is provided in the Read First thread. You have shown no evidence yet that you have in fact read it.
Now it would be nice if Dev-C++ provided the "press any key" service as a convenience, and it would have been simple for the developers to have implemented it, but they didn't, so live with it and stop railing against 'by design' behaviour.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see you too have missed the point entirely. That is exactly the same information provided in the "read first" thread he was directed to, so the question is answered.
Since that thread also contains a lot of other useful information he will want to know, (and he should have read it in any case, hence its name), it is useful to encourage the poster to go there for the answer rather than spoon feed it. If you do that they never gain any self reliance and keep coming back for more.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi all;
it's the first time i use Dev C++ and i liked it after a lot of stupid errors while useing MV Studio... and for the first time i had tried to test it and i wrote the following code:
include <iostream>
using namespace std;
int main(){
int list[5];
int sum=0;
No errors and also no warnings, but when built it then pressed on "RUN" the excution .exe appeares to me... and entered 1 2 3 4 5 then enter
but the .exe closed itself without no results.
log info:
Compiler: MhdBadi
Executing g++.exe...
g++.exe "C:\Documents and Settings\body\Desktop\maxmin.cpp" -o "C:\Documents and Settings\body\Desktop\maxmin.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
Execution terminated
Compilation successful
so i don't know why it closed itself before show the results
plz help me because i have a final exam after 2 days
note: i'm using Windows XP Professional SP3
It is normal behaviour in Windows (and probably all other GUI environments) that when a process terminates, its window is closed. Your program is not magically any different. If you did not write code to prevent your application from terminating, then it did exactly what you coded it to do.
This 'problem' is so common it is dealt with in the "PLEASE READ BEFORE POSTING A QUESTION*" thread in this very forum!
Some environments (such as VC++) execute IDE launched processes as a child process of another so that the program does not own the window so it does not close. Dev-C++ does not do that. Don't ask me why.
Another solution is to run the code in the debugger, with a breakpoint at the end of main(). But to be honest, if you get the debugger in Dev-C++ to work reliably, you are a better man than I. To be honest, you are going backward if you abandoned VC++ in favour of Dev-C++.
Clifford
Thanks a lot Clifford for your careness, but the point u didn't get is that any program u ever run must give you your result before closing the command window showing a sentense asking you to press any key to continue and run out from your program, but my one is running out before showing any results and that what am asking about.
Thanks again
> but the point u didn't get
I can assure you that I "got the point" and you are wrong. If you do not write your program to wait for a key press it should terminate.
The only reason that you get that help in VC++ is because your program is run within another program that does that for you.
> any program u ever run must give you your result before closing
Well that is not true, not all programs must necessarily have visible console output. However in your case the output was displayed, and your program terminated, and its window closed. The results were displayed for so short a time you did not see them.
> showing a sentense asking you to press any key to continue
Only if you either write that code to run from within an environment that does that for you. This is not normal behaviour and would be undesirable if say a program was to be executed as part of a batch process.
I suggest that you take any program that you wrote in VC++ where you expect the "press any key" prompt and run it directly from Explorer. You will find that it behaves in exactly the same way as running a program from within Dev-C++. The wait prompt is provided by the IDE not the compiler - it is not part of the application.
There was a time when this question came up two or three times a week or more. That is why the solution is provided in the Read First thread. You have shown no evidence yet that you have in fact read it.
Now it would be nice if Dev-C++ provided the "press any key" service as a convenience, and it would have been simple for the developers to have implemented it, but they didn't, so live with it and stop railing against 'by design' behaviour.
Clifford
I see this is an old thread, but, include these lines:
before the last }
lease do not "bump" old thread like this.
It interferes with current topics.
Wayne
I see you too have missed the point entirely. That is exactly the same information provided in the "read first" thread he was directed to, so the question is answered.
Since that thread also contains a lot of other useful information he will want to know, (and he should have read it in any case, hence its name), it is useful to encourage the poster to go there for the answer rather than spoon feed it. If you do that they never gain any self reliance and keep coming back for more.