Created
June 28, 2013 20:10
-
-
Save ranjib/5887708 to your computer and use it in GitHub Desktop.
And you think system administrators are grumpy ? :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/sysinfo.h> | |
#include <stdio.h> | |
int seconds2days(int seconds){ | |
return seconds/(60*60*24); | |
} | |
int days2year(int days){ | |
return days/365; | |
} | |
int main(argc){ | |
struct sysinfo info; | |
int uptime, age, exitstatus=0; | |
sysinfo(&info); | |
uptime = seconds2days((int) info.uptime); | |
uptime = 427; | |
age = days2year(uptime); | |
if (uptime < 1){ | |
printf("Im a new born!\n"); | |
} | |
else if((uptime % 365) == 0 ) | |
{ | |
printf("Happy '%d' birth day to you!\n", age); | |
exitstatus=1; | |
} | |
else | |
{ | |
printf("Im '%d' year , '%d' day old!\n", age, uptime%365); | |
} | |
return exitstatus; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment