[Question] Stop Console!

04/26/2013 19:25 Primmo#1
Hello,i'am just learning C++.


And i want to know how to stop a console while running , cause if i press 'Debug' it's closing immediately and this is my code, i already added system ("pause") but still not working any help? ^^




Source :

Code:
// C++ Hello All Tutorial by Primmo


#include <iostream>
#include <cstdio>

using namespace std; 


int main()
{

	 cout<<"Hello All!"<<endl;

	 system ("pause");
	 return 0;

}
04/26/2013 19:28 snow#2
std::cin.get();

Don't use system("pause");.
04/26/2013 19:28 Schlüsselbein#3
Start with CTRL+F5 or place a breakpoint at the end - thats it.
Console applications are not supposed to stay running after execution.
04/26/2013 19:30 Primmo#4
Quote:
Originally Posted by snow911 View Post
std::cin.get();

Don't use system("pause");.
Still not working :c.
04/26/2013 19:43 Cambios#5
while(true){} :P
04/26/2013 19:50 Primmo#6
Other suggestion ^^

Can someone re-create this source and giving me a working stop console source code ? :D
04/26/2013 19:52 Schlüsselbein#7
Again:
- set a breakpoint when starting from ide
- ctrl+f5 (when using visual studio)
- start your applications within a open command prompt

Its expected behaviour of console applications to exit after the code completes.
04/26/2013 19:53 Primmo#8
Quote:
Originally Posted by Schlüsselbein View Post
Again:
- set a breakpoint when starting from ide
- ctrl+f5 (when using visual studio)
- start your applications within a open command prompt

Its expected behaviour of console applications to exit after the code completes.
Thank you , but how you mean 'Breakpoint when starting from ide , i'am very sorry but i'am just a beginner Microsoft Visual C++.

#Fixed thanks ^^.
04/26/2013 20:01 Quack147#9
System pause is a great tool for starters. I still use it today.

As to why yours isn't working, I don't know. I even pasted it into visual studio on my computer and it worked.

What are you using?
04/26/2013 20:02 Primmo#10
Quote:
Originally Posted by Quack147 View Post
System pause is a great tool for starters. I still use it today.

As to why yours isn't working, I don't know. I even pasted it into visual studio on my computer and it worked.

What are you using?
Microsoft Visual C++ 2010 Express , and i setted Breakpoint like that guy said and its working but closing after like 4-5 seconds , and i want it for like permantly , that it won't close till pressing a key or press enter :D.
04/26/2013 20:03 Schlüsselbein#11
[Only registered and activated users can see links. Click Here To Register...]
click!
[Only registered and activated users can see links. Click Here To Register...]
04/26/2013 20:05 Primmo#12
Quote:
Originally Posted by Schlüsselbein View Post
[Only registered and activated users can see links. Click Here To Register...]
click!
[Only registered and activated users can see links. Click Here To Register...]
Bro,its still closing , :D. Even i added Breakpoint in Ide }
04/26/2013 20:05 Schlüsselbein#13
Quote:
Microsoft Visual C++ 2010 Express , and i setted Breakpoint like that guy said and its working but closing after like 4-5 seconds , and i want it for like permantly , that it won't close till pressing a key or press enter .
Look at programs like ping, netstat or any other popular console applications. Its the way console applications work. Its not the applications job to decide whether the console should stay open or not. It gives the responsibility back to the caller. If you want to see the output, start your app out of a open shell.

Quote:
Bro,its still closing , . Even i added Breakpoint in Ide }
Start your program with debugger _attached_ (F5 solo!) after setting the breakpoint. No debugging features without an attached debugger, conclusive mh?
04/26/2013 20:06 Quack147#14
Quote:
Originally Posted by Primmo View Post
Microsoft Visual C++ 2010 Express , and i setted Breakpoint like that guy said and its working but closing after like 4-5 seconds , and i want it for like permantly , that it won't close till pressing a key or press enter :D.
It shouldn't do that. Try setting your breakpoint by clicking on the gray bar left of your code. It should make a red circle appear like this.

[Only registered and activated users can see links. Click Here To Register...]

Then when you want to resume your code after it hits the breakpoint, click the play symbol. It should freeze there until you do that, if you set it correctly.
04/26/2013 20:19 Cambios#15
Quote:
Originally Posted by Primmo View Post
Thank you , but how you mean 'Breakpoint when starting from ide , i'am very sorry but i'am just a beginner Microsoft Visual C++.

#Fixed thanks ^^.
He had trolled you.. :rolleyes:
IDA = IDA PRO (Decompiler & Debugger)
breakpoint = debugging and a break within the programm running