time...without seconds in C!!
well i had been able to figure out how to get time in hours and minutes..not the seconds.....
the following code gives me time as...10:30:23...hh:mm:sec
i want only hh:min
can anyone sugest how i can do this
#define SIZE 256
struct tm *loctime;
/* Get the current time. */
curtime = time (NULL);
/* Convert it to local time representation. */
loctime = localtime (&curtime);
/* Print out the date and time in the standard format. */
fputs (asctime (loctime), stdout);
/* Print it out in a nice format. */
strftime (buffer1, SIZE, " %x\n", loctime);
strftime (buffer2, SIZE, "%X", loctime);
Check out the other format specifiers on the man page for strftime (or in the help file entry for strftime).
There are lots more options that look interesting, so I recommend reading it yourself.
BTW, thanks. I had never looked at strftime before.