Run from command line

This is a discussion on Run from command line within the C++ Programming forums, part of the General Programming Boards category; Hello, my John Strobel. I started teaching myself C++ with books and tutorials earlier this week. I had written a ...

Run from command line

Hello, my John Strobel. I started teaching myself C++ with books and tutorials earlier this week. I had written a sample code from a book and ran it, it takes the imput but never produces output after i hit enter. I apologize for such a trivial question, but how do I run the program from a command line prompt, or window? Instead of compile and run.

Thank you for any help, I may be a bit short sighted with something so simple

Does the window close after you enter your input? This is very likely since it will flow immediately to the return. You can slow it down by putting a getchar() before return which will wait for you to press a button. That way you don't have to worry about navigating the command prompt.

Does the window close after you enter your input? This is very likely since it will flow immediately to the return. You can slow it down by putting a getchar() before return which will wait for you to press a button. That way you don't have to worry about navigating the command prompt.

or include <cstdlib> and at the end or you codes , before "return 0;" write system("pause");
this should do it . no need to test your code out put using a cmd!

"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."