0

Hey guys pls look at my code for time I want it to be able to say between 08h00 and 17h00 I'm at work else I'm at home

#include <ctime> #include <iostream> using namespace std; int main() { time_t t = time(0); // get time now struct tm * now = localtime( & t ); cout << "Date and Time" << endl << "_________" << endl << endl << (now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday << endl << (now->tm_hour +2) << ':' << now->tm_min << ':' << now->tm_sec <<

23rd Nov 2016, 4:45 PM
Damian Vosloo
Damian Vosloo - avatar
2 ответов
0
I get it to say work time but my else ain't running what have a forgot to do
23rd Nov 2016, 4:46 PM
Damian Vosloo
Damian Vosloo - avatar
0
#include <ctime> #include <iostream> using namespace std; int main() { time_t t = time(0); struct tm * now = localtime( & t ); if(now->tm_hour + 2 >= 8 && now->tm_hour + 2 <= 16){ cout << "I am at work." << endl; } else { cout << "I am at home." << endl; } return 0; }
24th Nov 2016, 4:27 PM
Isko