An input variable takes both double and string?
I'm making a timezone converting program. Sample outputs are here:
$ echo "noon HST EET" | ./a.out
midnight
$ echo "11:29 a.m. EST GMT" | ./a.out
4:29 p.m.
when user inputs "noon", my program won't work. Below is my code for inputs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
string current_timezone;
string desire_timezone;
int currentHour, currentMin;
char sym;
int utc_time = 0;
int converted_time = 0;
//am pm
char ap1;
char pt1;
char ap2;
char pt2;
cin >> currentHour >> sym >> currentMin >> ap1 >> pt1 >> ap2 >> pt2 >> current_timezone >> desire_timezone;}
|
how can I deal with this situation? please ask me anything for clarifications.
Last edited on
Read the input into a string and parse the string (checking for all valid forms).
The regular expression library may be handy.
Topic archived. No new replies allowed.