Untitled
unknown
plain_text
a year ago
1.0 kB
9
Indexable
// note: {0} is explicit initialization.
#include <iostream>
using namespace std;
struct Date {
string day;
string month;
string year;
};
void printDateDMY(Date date) { // does this work?
cout << "The Current Date (in Day/Month/Year) Format Is:" << endl;
cout << date.day << '/' << date.month << '/' << date.year << endl; // DMY FORMAT
}
void printDateMDY(Date date) {
cout << "The Current Date (in Month/Day/Year) Format Is:" << endl;
cout << date.month << '/' << date.day << '/' << date.year << endl;
}
struct Date getDate() {
Date date; // i should only have to create one instance of the date struct right?
cout << "Day:" << endl; // could someone please tell me if this is okay code (copied from an example website)?
cin >> date.day;
cout << "Month:" << endl;
cin >> date.month;
cout << "Year:" << endl;
cin >> date.year;
cin.sync();
return date;
}
int main() {
Date date = getDate(); // this seems like bad code, i dunno.
printDateDMY(date);
printDateMDY(date);
return 0;
}
Editor is loading...
Leave a Comment