system pause (quick)

browserjoe

In Runtime
Messages
173
so im starting to learn c++, and im on my first tutorial (hello world)

and then when i compile and run it the dos thing will just go up for a split second

i know the way to fix this is to insert a line of code that contains the word "system" and "pause" and some symbols at the end, but i forgot which symbols/ what order you put them in.
 
it is just system(pause);

but that's not strictly true...

your program works fine, it starts it runs, it terminates.


try using the command prompt to run your program. that way the console will stay open so that you can actually see it say hello world.
 
Isn't system(pause); a partially-Windows specific function call? When I compiled that on gcc on the Mac it flagged up a warning.
 
system();

is non-specific it's the C syntax for making a call that is to a system procedure or program,

so system('notepad.exe'); starts notepad. (on windows)

pause is specific to windows,
might be available on Linux, not sure.
 
Back
Top Bottom