• C

C, how to get minute value

I just want to get the current minute of from the current time.  I am using C on Linux OS.  Also be sure that there's no memory leak, since I am in an infinite loop reading the minute value.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

man localtime
rgbcofAuthor Commented:
let me rephrase the questions, I just want seconds since epoch.
man 3 time
Olivier HupéCommented:
This should be a good start :

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char*argv[])
struct tm *tm;
time_t t;
int loop=0;
while (loop<1000)
if(time(&t) == (time_t) -1) printf("Something is rotten around here\n");
else {
	if (tm) printf("Current minute:second : %2d:%2d\n",tm->tm_min,tm->tm_sec);
	else printf("localtime failed\n");



Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgbcofAuthor Commented:
Very close to what I was looking for.  Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.