0

I'm trying to take time input from the user '11:59 AM' but as soon as I give input it terminates.

Input format of 'p' is 11:59 AM and of 's' is 10:00 AM 11:00 AM

string p;
getline(cin,p);
int n;
cin>>n;
vector <string> v(n);
int meet=meetTime(p);
cout<<p<<endl;
for(int i=0;i<n;i++){
    string s;
    getline(cin,s);
    //11:59 AM 12:00 PM
    v[i]=s;
}
Xtreme
  • 1
  • 1
  • I suspect your code suffers from this problem - https://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction – R Sahu Feb 11 '21 at 05:41
  • 2
    Why are you spam tagging? [exception] is not for questions that do not give exceptions. [c++14] probably isn't necessary either, use it for questions specific to c++14 – mediocrevegetable1 Feb 11 '21 at 05:41
  • 1
    Please show a [mre]. Have you tried using a debugger? – Alan Birtles Feb 11 '21 at 07:03
  • @mediocrevegetable1, please be fair to a newcomer here! For a beginner, it might look like a (non-caught) exception might have lead to the terminate. – Secundi Feb 11 '21 at 08:11
  • 1
    @Secundi Indeed, I guess that could be a possibility. Nonetheless, it's strange OP chose the exception tag; either they haven't learnt exceptions yet, in which case they probably shouldn't have tagged something they weren't 100% sure about; or they knew about exceptions, in which case they would know that exceptions gave an error message if uncaught – mediocrevegetable1 Feb 11 '21 at 08:20

0 Answers0