[try Beta version]
Not logged in

 
system("pause") won't work for me

Feb 23, 2011 at 3:52pm
error: 'system' was not declared in this scope

I don't know why, please help me, thank you in advance.

PS: I use Code::Blocks10.05, what do you guys use?
Last edited on Feb 23, 2011 at 3:52pm
Feb 23, 2011 at 3:55pm
It's because of your compiler. If I am correct, "system("PAUSE");" only works on Windows computers.

If you are using <iostream>, try:
 
cin.get();
Feb 23, 2011 at 3:58pm
@Cuddly

cin.get(); works for me, but why 'system' won't?

My OS is Windows 7 SP1.
Feb 23, 2011 at 4:01pm
error: 'system' was not declared in this scope

means that your compiler has never heard of such a thing as system, because you have not declared it. You can include the declaration by including the cstdlib header, i.e.
 
#include <cstdlib> 


Use of system is frowned upon because it asks the shell you are executing in to run some other programme for you. You have no guarantee that the other programme exists, and no guarantee that it does what you want.

If you just want to pause your programme, do as the Kitten says, or alternatively if you just want the console window to remain visible, run your programme from a console.
Last edited on Feb 23, 2011 at 4:02pm
Feb 23, 2011 at 4:10pm
There's no need to pause the program if you run it from C::B since it will pause it for you ( you can toggle this on the project settings )
Feb 23, 2011 at 4:11pm
Problem solved. Thank you, @Cuddly, @Moschops.
Feb 23, 2011 at 4:15pm
@Bazzy

But it won't pause for me. What is the exact location of the setting?
Feb 23, 2011 at 4:22pm
Project Properties > Build Targets > Pause when execution ends
Feb 23, 2011 at 4:27pm
@Bazzy

I see, it won't pause for me because what I've been editing is a file not a project. Thank you very much.
Feb 23, 2011 at 5:02pm
isn't it has to be capital?

SYSTEM("PAUSE");

CMIIW
Feb 23, 2011 at 5:12pm
SYSTEM() does not exists as function and Windows commands are not case sensitive ( so "pause" and "PAUSE" should be the same )
Topic archived. No new replies allowed.