Hi, I'm very new at this and am atempting to follow this sites tutorial it is helping me learn but the first example th Helo World one wont stay open when i run it. It just opens then instantly closes. I am using Bloodshed Dev-C++ if that helps. any help wil be greatly appreciated.
An alternative way is to press Windows+R, then type in 'cmd'. Then navigate to the directory that the .exe is in, and type in the program's name without the .exe extension. That way, it will run the program and close, but you'll see the output of it.
I have the exact same problem, and i know i can fix it using one of the above options, but I'd like to stick to the book as much as I can, so is there any way i can change the settings so that I don't need to use those solutions?
1 2 3 4 5 6 7 8 9
include <iostream>
usingnamespace std;
int main()
{
cout <<"Never fear, C++ is here!"return 0;
}
dgo: The proper way to do it would be to run it from the console. When you think about it, you want the program to stop as soon as it's finished doing whatever it's going to be doing. It's not up to the application to give the user time to read it, it's up to the operating system handling the stdout. This is why I miss Linux :(
But if you use Code::Blocks, you can choose 'Build & Run', which will compile your program, run it, and pause for you at the end.
No, merely that you press Control+R, type in 'cmd', and then navigate to the directory it's saved in. Then, you can run the program from there. The program will close instantly, but the little black rectangle window (ie. the console window) will not close.
Though, if you want to go ahead and use Linux, feel free. It's made for programmers :).
include <iostream>
usingnamespace std;
int main()
{
cout <<"Never fear, C++ is here!"
system("PAUSE");
return 0;
}
For any book examples, you just have to add that system("pause") message before your return 0 in main....Or you could use the system("pause>nul"); as well....either will work.