#include #include #include //for the functions time and localtime using namespace std; int main() { //Get the current day of the week (0 to 6 inclusive, 0 means Sunday). time_t t {time(nullptr)}; tm *p {localtime(&t)}; int weekday {p->tm_wday}; switch (weekday) { case 0: cout << "Sunday"; break; case 1: cout << "Monday"; break; case 2: cout << "Tuesday"; break; case 3: cout << "Wednesday"; break; case 4: cout << "Thursday"; break; case 5: cout << "Friday"; break; case 6: cout << "Saturday"; break; default: //none of the above cerr << "Bad weekday " << weekday << " should have been in range 0 to 6 inclusive.\n"; return EXIT_FAILURE; break; } //Each break sends us to this point, right after the end of the switch. cout << "\n"; return EXIT_SUCCESS; }