0

我正在编写一个程序来计算和打印我正在使用 get.line 供用户输入的停车费,我如何使用“查找”来分隔行?

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
string enter_date;
string enter_time;
string exit_date;
string exit_time;
int calculatecharge;
int num;

cout << "Please enter the date and time the car is entering "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
getline (cin,enter_date);
getline (cin,enter_time);
cout<< "Please enter the date and time the car is exiting "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
getline (cin,exit_date);
getline (cin,exit_time);

find(' ')


cout<<"Parking fee due: "<< num << endl;
return 0;
}
4

1 回答 1

0

如果您使用 getline() 两次,请尝试以下代码。

getline (cin, enter_date, ' ');
getline (cin, enter_time);
于 2012-04-04T08:43:44.657 回答