我正在尝试开发一个程序,它等待特定时间段的输入,并在 c++ 中一段时间后出来,就像我们在 atm 机器中所做的那样。任何人都可以尝试帮助我。
#include <iostream>
#include <ctime>
#include<string>
using namespace std;
int main(){
string name;
cout << "Enter your name: ";
int endTime= 5;
int i=0;
// cout<<endTime<<endl;
while(i < endTime)
{
getline(cin, name);
i++;
endTime--;
if( i > endTime && (name.empty()))
break;
}
cout << "NO NAME ENTERED!!" << endl;