Basically, im a first year electrical engineering student, and im just about to move up to the second year come september. Now that I dont have access to the university's computers, im using my own personal pc to carry on my studies and keep in practice for next term.
The problems i am having are on windows vista home basic. After compliing, when I execute the window flashes up and disapears very quickly. I have used the "system("PAUSE");" function, but that results in having a message at the bottom of the window saying "please press any button to continue"
Now I have read the FAQ's about this problem, but to be honest, its not written in plain enough english for me to understand, so im a bit lost for what I shout do to get things working again without extra messages popping up.
If anyone could possibly explain a fix for this in simple english (you can always pretend you talking your non-programmer wife's / husbands, or 6 year old!)
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You applied the fix and say that it did not work. You say you read the FAQ, but you omitted the very first thing it mentions. Where is your code, and where is your build log!?
system( "pause" ) runs the pause command via cmd.exe; printing "please press any button to continue" is exactly what it is supposed to do (you can try it from the command line). What did you expect - sounds like it solved your problem to me, and the real problem is that your code did not do what you expected. But we cannot read minds. When a program terminates, the operating system closes its window, that's all. All program's work that way, but people seem surprised when it happens to theirs!
Anyway, all that said, if you want to get real work done, and have no compelling or specific reason to use Dev-C++ (like it is a course requirement or something), then I suggest that you use Microsoft's free Visual C++ Express Edition. Unlike Dev-C++ it has a usable and working debugger which you will find invaluable in your studies. I suggest that right after you create your first 'hello world' program with it, you do nothing else until you have learned to execute, step, set break points, and watch variables in the debugger (there's more, but that will do to start) - it will take you less than an hour, but will save you many hours in the future.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry my expliation wasnt very good, what I ment to say was, I had the problem when executing a program would result with the program opening for a short time, and closing right away, so qick it seems to flash on and off.
I used the fix in the FAQ with the system ("PAUSE") function, I had never heard about this command before, and tho it worked with keeping the exe open, it displayed the text "click to continue" ect.
There are other fixes listed on the FAQ, but as I said before, I dont understand what they mean or how to use them.
As a engineering student , im taught the very basics, but instead of understanding how everything works, I only have a basic knowledge of how things work together, and I havnt come across a lot of programming terms making finding help online differcult.
Sorry I didnt include my sourcecode, but as my question wasnt specific to any code, I thort I could miss that out.
So again im sorry about that, and I will include a hello world code now.
include <stdio.h>
int main()
{
printf("Hello world");
system("PAUSE");
;return(0);
}
I also use dev c++ as it was the enviroment program I was taught at uni, and out of sheer habit I thort I could use it at home also.
Thanks again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>> There are other fixes listed on the FAQ, but as I said before,
>> I dont understand what they mean or how to use them.
Ok. As I explained. When a program finishes, its window closes. The only time this is not true, is when it has no window of its own and is running in some other processes window. This is the case, for example, when you run a program from the command line (if you don't know heat that is see http://commandwindows.com/ ).
Because console applications (text mode) as opposed to GUI applications do not necessarily have to be explicitly closed down by a user (by File->Exit, or clocking the X button for example), this behaviour sometimes surprises people. The problem is that if the program is not interactive (i.e. hangs around for the user to poke it), it does its job, finishes, and gets closed. The purpose of the system("pause") call is merely to force your program to stop and wait before it finally terminates. It is not normally something that you would put in your code - more sophisticated applications might naturally include interactivity via a menu system for example, or would loop indefinitely doing its job until some explicit action by the user to cause it to quit. Sometimes a program may be designed to be specifically non-interactive - a batch file utility for example. If for example you had some process that had to run overnight, and included a call to your program, you would be annoyed if in the morning you cane in and it had had not completed the job because it was waiting for a user to 'press any key'! It is just something put in there temporarily during program development, or when developing typical 'class exercise' code.
The alternative is to run your console programs from the command line. If you do that I recommend installing the Microsoft CommandHere Power Toy utility. It allows you to open a command prompt from Explorer with the working directory set to the selected folder.
I am not really sure what you want as a solution if system("pause") does not meet your expectation. What do you want it to do? I am also surprised that you have not encountered this issue previously if you have use the tool in class.
Any method of waiting for user input will suffice. The advantage of system("pause") is that it is immune to the often unexpected effects of unused input in the input buffer (another FAQ!).
If you use MSVC++ and run console code without the debugger from the IDE, it will still display 'press a key to continue' but you don't have to put the system("pause") call in. This is because it runs the code in a wrapper precess that has ownership of the window, so your program terminates, but the window stays open. It is the wrapper that displays the 'press a key' message. If however you run the code in the debugger, you will need a breakpoint set at the end to stop it from closing.
I would suggest that you build and test your code in MSVC++ and perhaps for assignments recompile it in Dev-C++ merely to check works in the course mandated compiler before submission. You might suggest that your department take advantage of Microsoft's free offering - it is far superior to Dev-C++ in all but perhaps start-up time and disk footprint; its huge, and annoying slow to open projects, but disk space is cheap, and opening a project is about 0.01% of your development time! http://www.microsoft.com/express/vc/
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hiya,
Im using dev c++ version 4.9.9.2
Basically, im a first year electrical engineering student, and im just about to move up to the second year come september. Now that I dont have access to the university's computers, im using my own personal pc to carry on my studies and keep in practice for next term.
The problems i am having are on windows vista home basic. After compliing, when I execute the window flashes up and disapears very quickly. I have used the "system("PAUSE");" function, but that results in having a message at the bottom of the window saying "please press any button to continue"
Now I have read the FAQ's about this problem, but to be honest, its not written in plain enough english for me to understand, so im a bit lost for what I shout do to get things working again without extra messages popping up.
If anyone could possibly explain a fix for this in simple english (you can always pretend you talking your non-programmer wife's / husbands, or 6 year old!)
Thanks in advance.
You applied the fix and say that it did not work. You say you read the FAQ, but you omitted the very first thing it mentions. Where is your code, and where is your build log!?
system( "pause" ) runs the pause command via cmd.exe; printing "please press any button to continue" is exactly what it is supposed to do (you can try it from the command line). What did you expect - sounds like it solved your problem to me, and the real problem is that your code did not do what you expected. But we cannot read minds. When a program terminates, the operating system closes its window, that's all. All program's work that way, but people seem surprised when it happens to theirs!
Anyway, all that said, if you want to get real work done, and have no compelling or specific reason to use Dev-C++ (like it is a course requirement or something), then I suggest that you use Microsoft's free Visual C++ Express Edition. Unlike Dev-C++ it has a usable and working debugger which you will find invaluable in your studies. I suggest that right after you create your first 'hello world' program with it, you do nothing else until you have learned to execute, step, set break points, and watch variables in the debugger (there's more, but that will do to start) - it will take you less than an hour, but will save you many hours in the future.
Clifford
Sorry my expliation wasnt very good, what I ment to say was, I had the problem when executing a program would result with the program opening for a short time, and closing right away, so qick it seems to flash on and off.
I used the fix in the FAQ with the system ("PAUSE") function, I had never heard about this command before, and tho it worked with keeping the exe open, it displayed the text "click to continue" ect.
There are other fixes listed on the FAQ, but as I said before, I dont understand what they mean or how to use them.
As a engineering student , im taught the very basics, but instead of understanding how everything works, I only have a basic knowledge of how things work together, and I havnt come across a lot of programming terms making finding help online differcult.
Sorry I didnt include my sourcecode, but as my question wasnt specific to any code, I thort I could miss that out.
So again im sorry about that, and I will include a hello world code now.
include <stdio.h>
int main()
{
printf("Hello world");
system("PAUSE");
;return(0);
}
I also use dev c++ as it was the enviroment program I was taught at uni, and out of sheer habit I thort I could use it at home also.
Thanks again.
>> There are other fixes listed on the FAQ, but as I said before,
>> I dont understand what they mean or how to use them.
Ok. As I explained. When a program finishes, its window closes. The only time this is not true, is when it has no window of its own and is running in some other processes window. This is the case, for example, when you run a program from the command line (if you don't know heat that is see http://commandwindows.com/ ).
Because console applications (text mode) as opposed to GUI applications do not necessarily have to be explicitly closed down by a user (by File->Exit, or clocking the X button for example), this behaviour sometimes surprises people. The problem is that if the program is not interactive (i.e. hangs around for the user to poke it), it does its job, finishes, and gets closed. The purpose of the system("pause") call is merely to force your program to stop and wait before it finally terminates. It is not normally something that you would put in your code - more sophisticated applications might naturally include interactivity via a menu system for example, or would loop indefinitely doing its job until some explicit action by the user to cause it to quit. Sometimes a program may be designed to be specifically non-interactive - a batch file utility for example. If for example you had some process that had to run overnight, and included a call to your program, you would be annoyed if in the morning you cane in and it had had not completed the job because it was waiting for a user to 'press any key'! It is just something put in there temporarily during program development, or when developing typical 'class exercise' code.
The alternative is to run your console programs from the command line. If you do that I recommend installing the Microsoft CommandHere Power Toy utility. It allows you to open a command prompt from Explorer with the working directory set to the selected folder.
I am not really sure what you want as a solution if system("pause") does not meet your expectation. What do you want it to do? I am also surprised that you have not encountered this issue previously if you have use the tool in class.
Any method of waiting for user input will suffice. The advantage of system("pause") is that it is immune to the often unexpected effects of unused input in the input buffer (another FAQ!).
If you use MSVC++ and run console code without the debugger from the IDE, it will still display 'press a key to continue' but you don't have to put the system("pause") call in. This is because it runs the code in a wrapper precess that has ownership of the window, so your program terminates, but the window stays open. It is the wrapper that displays the 'press a key' message. If however you run the code in the debugger, you will need a breakpoint set at the end to stop it from closing.
I would suggest that you build and test your code in MSVC++ and perhaps for assignments recompile it in Dev-C++ merely to check works in the course mandated compiler before submission. You might suggest that your department take advantage of Microsoft's free offering - it is far superior to Dev-C++ in all but perhaps start-up time and disk footprint; its huge, and annoying slow to open projects, but disk space is cheap, and opening a project is about 0.01% of your development time! http://www.microsoft.com/express/vc/
Clifford