User forums > Using Code::Blocks

system("pause") command

<< < (2/2)

jvnetsl:
You Must include Windows header file to do that.. <windows.h>
so include this,
#include <windows.h>

Hope this helps..... :) :) :) :) :) :) :) :) :) :) :)

JV net works..

zabzonk:
> The standard doesn't contain "system", and it's not portable.

system() is part of both the C and C++ standards, which declare it in stdlib.h (or cstdlib).

Alpha:

--- Quote from: xunxun on November 18, 2010, 06:40:19 pm ---You can try to use "cin.get()" to pause the execution.

--- End quote ---
To use cin.get() to pause execution, you might have to call cin.sync() first.


--- Quote from: Neil Butterworth on November 25, 2011, 12:42:01 pm ---> The standard doesn't contain "system", and it's not portable.

system() is part of both the C and C++ standards, which must declare it in stdlib.h (or cstdlib).

--- End quote ---
I think it is more that the "Pause" that system() is calling is an executable that must exist in the current path; it may or may not exist/function in the same manor - depending on where the program is run - (or could possible be a virus hoping that you will run it by mistake!).  (It is also misuse of system(), as forcing the OS to search through the path and load a new program just to pause execution, is a huge amount of overhead to achieve a very tiny function.)

Navigation

[0] Message Index

[*] Previous page

Go to full version