tod.c
Michael Foster Rivero
rivero at kovacs.UUCP
Tue Jan 15 03:31:57 AEST 1985
I really liked the tod.c posted to net.sources, but decided it should
be a little more personal, so I hacked it to use your login name in
the messages. Enjoy!
-----------------CUT HERE---------------------------------------------------
#include <stdio.h>
#include <time.h>
struct tm *localtime ();
struct tm *loc_time;
main ()
{
long clock;
char tod[5];
int t_hour, t_min, daytime, tnum;
char *name;
char *getlogin();
name = getlogin();
time (&clock);
loc_time = localtime (&clock);
t_hour = loc_time->tm_hour;
t_min = loc_time->tm_min;
sprintf (tod, "%2d%02d", t_hour, t_min);
daytime = 5; /* Not sure what time it is? */
tnum = atoi (tod);
if (tnum >= 0500 && tnum <= 1159) /* it's morning */
daytime = 0;
if (tnum >= 1200 && tnum <= 1759) /* it's afternoon */
daytime = 1;
if (tnum >= 1800 && tnum <= 2359) /* it's evening */
daytime = 2;
if (tnum >= 0000 && tnum <= 0459) /* it's late! */
daytime = 3;
switch(daytime)
{
case 0:
printf ("\nGood Morning %s!\n",name);
break;
case 1:
printf ("\nGood Afternoon %s!\n Only a few more hours to go.",name);
break;
case 2:
printf ("\nGood Evening %s!\n Working late again, I see!\n",name);
break;
case 3:
printf ("\nHey %s!\n Why are you working at this time of night?\n",name);
break;
case 4:
printf ("\nI don't even know what time it is %s\n",name);
}
}
-----------------CUT HERE---------------------------------------------------
Mike Rivero
randvax!kovacs!rivero
More information about the Comp.sources.unix
mailing list