In this tutorial, I show you how to use cin.get() in C++ instead of system("pause") to end your programs in a very simple way using an older program. I don't get into anything too heavy or too new.
cin.get() is far more efficient and unlike system("pause"), this should work in non-windows environment without a problem. If you have any questions about the program or functions in general, feel free to ask.
I hope you enjoy the video and if you have any requests feel free to let me know.
Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.
//Programmer: Nazmus //Program: cin.get() //Website: EasyProgramming.net #include#include using namespace std; int main() { int max, random_number, i; for(i=1;i<=5;i=i+1){ cout << "Please input max integer: "; cin >> max; srand(time(0)); random_number = (rand () % max) + 1; cout << random_number << endl; } cin.ignore(); cin.get(); }#include