Changing a string date to an array spot

closed account (9hv4jE8b)
I'm trying to take a string date (m dd) and turn it into an array spot.
This is a hotel reservation simulation and my hotel is only open in June (30 days), July (31 days), and August (31 days), the user must enter in (m dd) format. So i was thinking I could determine what the first number in the string is 6, 7, or 8 and make those equal to 0, 30, and 61 and subsequently add the dd number. For example (6 12) is 0+12, the 11th array spot. (7 3) is 30+3=33, the 32nd array spot.
I don't really know how to determine what is actually in the string.

This may not be the best approach, I'm open to ideas.
closed account (9hv4jE8b)
Ok so I'm using a substring and it looks like this:
1
2
3
4
5
6
7
8
9
10
  cout << "Please select room: ";
            cin >> whichRoom;                          
            cout << "Please select the initial date (m dd): ";
            cin >> dateofstay;                            
            cout << "Please select number of days: ";                            
            cin >> howlong;
            month= dateofstay.substr(0,1);     
            day= dateofstay.substr(2,2);
            cout << month;
            cout << day <<endl;


But this wont compile. When I comment out the day=... and cout << day it works fine and outputs month correctly. Can anyone tell me whats wrong?
Also it skips cin >> howlong and I'm not sure why that is either
Topic archived. No new replies allowed.