basically, i want this person to tell me the expiration date of a food product and they have to enter it in the form of mm/dd/yyyy
then i want to return to them the day they entered so the program would look like this:
Enter expiration date in the form mm/dd/yyyy: 3/19/2008
You said the expiration day was the: 19
below is what ive been trying to put into visual studio, but it wont work, im not sure how exactly to have an input in the form of mm/dd/yyyy and then be able to store the month 'm' day 'd' and year 'y' as seperate variable, could you please correct what i have entered below to how it should look?
cout << "Enter expiration date in the form mm/dd/yyyy: ";
cin >> m;
cin >> d;
cin >> y;
cout << "You said that the expiration day was the" << d << endl;
2007-03-19
11:07:15
·
4 answers
·
asked by
63godtoh
3
in
Computers & Internet
➔ Programming & Design
seriously, both the first responses were perfect, but i messed up...
in some of the examples of what im suppose to do here, the inputs from the user using the program could enter '2' instead of '02' into the month section for example
so with that new information, does anyone know how to go about doing this?
if i still used the string and .substr, i would end up getting a slash in the variable, unless there is some other way of going about doing that
anything will be helpful, thanks!
2007-03-19
11:45:14 ·
update #1