1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include <iostream>
#include <string>
using namespace std;
string getMonth(string);
void pause();
int main()
{
string date,
month,
day,
year;
cout << "\n\n This program will ask you to enter the dat in the following\n"
<< " format: mm/dd/yyyy.";
cout << "\n\n\tEnter date:";
getline(cin, date);
month = date.substr(2,0);
month = getMonth(month);
day = date.substr(2,3);
year = date.substr(4,6);
date.clear();
date = month;
date.append(" ");
date.append(day);
date.append(", ");
date.append(year);
date.append(".");
pause();
return(0);
}
string getMonth(string m)
{
string months[12] = {"January", "February", "March", "April",
"May", "June", "July", "August",
"September","October", "November", "December"};
int month;
month = stoi(m);
m = months[month];
return(m);
}
void pause()
{
cout << "\n\nPress enter to continue...";
cin. sync();
cin.get();
cout << "\n\n";
return;
}
|