Hey, I am trying to write a program that allows someone to enter two separate dates and returns the later of the two. I.E. I input 2/14/2004 and 3/2/2004, so it outputs 3/2/2004. This is what I have so far:
I keep getting errors on the getline parts and I'm not quite sure what is wrong with it. Any help is greatly appreciated.
Code:
#include <iostream> #include <istream> #include <iomanip> #include <string> #include <cstdlib> using namespace std; struct Date { int month; int day; int year; }array[2]; int larger (Date array[]); int main() { int i; for (i=1; i<=2; i++) { cout <<"Please enter a month : "; cin.getline (array[i].month); cout <<"Please enter a day : "; cin.getline (array[i].day); cout <<"Please enter a year : "; cin.getline (array[i].year); } cout <<"The larger of the two dates is " <<larger(array) <<endl; system("PAUSE"); return 0; } int larger(Date array[]) { int l, i; if (a[1] > a [2]) l=a[1]; return l; }
Comment