我正在写一个计算和打印停车费的程序,我正在使用get.line让用户输入,我如何使用"find“来分隔行?
#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;
}发布于 2012-04-04 16:43:45
如果要使用getline()两次,请尝试下面的代码。
getline (cin, enter_date, ' ');
getline (cin, enter_time);https://stackoverflow.com/questions/10004621
复制相似问题