This is what I have so far. Everything works fine except for the fact that instead of displaying 06 or 07 it displays only 6 or 7. And the year only works properly above 2000. Under it displays three integers instead of two. Like for 1990 it would show 990 instead of 90.
#include <conio.h>
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
bool GetDate(int* dptr, int* mptr, int* yptr)
{
string date, day, month, year;
cout << "\n Please enter a date: ";
getline(cin, date);
month = date.substr(0, 3);
day = date.substr(4, 2);
year = date.substr(8, 4);
string month_array[12] = { "jan","feb","mar","apr","may","jun",
"jul","aug","sep","oct","nov","dec" };
for (int i = 0; i < 12; ++i)
if (month == month_array[i])
*mptr = i + 1;
*dptr = stoi(day);
*yptr = stoi(year);
return true;
}
int main()
{
int day, month, year;
int* d = &day, * m = &month, * y = &year;
if (GetDate(d, m, y))
cout << "\n\n\n date is: " << *m << "/" << *d << "/" << *y;
else
cout << "incorrect date";
_getch();
return 0;
}