I'm writing a program that converts a short date (mm/dd/yyyy) to a long date (March 12, 2014) and prints out the date.
The program has to work given the following user inputs: 10/23/2014 9/25/2014 12/8/2015 1/1/2016
I have the program working with the first user input but I'm not sure how to proceed with handling a user input that doesn't have a "0" in the first position of the string.
#include <iostream>
#include <string>
using namespace std;
int main() 
{
    string date; 
    cout << "Enter a date (mm/dd/yyyy): " << endl;
    getline(cin, date);
    string month, day, year;
    // Extract month, day, and year from date
    month = date.substr(0, 2);
    day = date.substr(3, 2);
    year = date.substr(6, 4);
    // Check what month it is 
    if (month == "01") {
        month = "January";
    }
    else if (month == "02") {
        month = "February";
    } 
    else if (month == "03") {
        month = "March";
    } 
    else if (month == "04") {
        month = "April";
    } 
    else if (month == "05") {
        month = "May";
    } 
    else if (month == "06") {
        month = "June";
    } 
    else if (month == "07") {
        month = "July";
    } 
    else if (month == "08") {
        month = "August";
    } 
    else if (month == "09") {
        month = "September";
    } 
    else if (month == "10") {
        month = "October";
    } 
    else if (month == "11") {
        month = "November";
    } 
    else {
        month = "December";
    }
    // Print the date
    cout << month << " " << day << "," << year << endl;
    return 0;
}
I'd greatly appreciate any help.
 
     
    