当我通过命令行运行一个程序时,一旦程序结束,cmd会立即关闭,所以我看不到输出。有没有办法阻止这种情况发生,这样我才能真正验证输出?
#include<iostream>
using namespace std;
class Exercises {
public:
void sayHello(int x) {
for (int i = 0; i < x; i++)
cout << "Hello!!" << endl;
}
}exercise;
int main() {
exercise.sayHello(4);
return 0;
}