首页
学习
活动
专区
圈层
工具
发布

c++编程
EN

Stack Overflow用户
提问于 2012-04-04 11:42:27
回答 1查看 867关注 0票数 0

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

代码语言:javascript
复制
#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;
}
EN

回答 1

Stack Overflow用户

发布于 2012-04-04 16:43:45

如果要使用getline()两次,请尝试下面的代码。

代码语言:javascript
复制
getline (cin, enter_date, ' ');
getline (cin, enter_time);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10004621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档