Solved

Displaying the time on unix using C

Posted on 1998-06-16
3
153 Views
Last Modified: 2010-04-15
I've been using localtime() to display the time on a Sun Workstation (Solaris 5.X) but I don't get the right time. The time that I get on the tm structure is 11/31/69. Note that I use the clock() function to retrieve the time_t structure needed by localtime(). So it my be the clock() function that is not working.
0
Comment
Question by:doscar
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1251237
#include <time.h>

 time_t t;
 t = time(NULL);
 printf("%s",asctime(localtime(&t)));
0
 
LVL 4

Accepted Solution

by:
sganta earned 70 total points
ID: 1251238
you can display using
system(date);
0
 

Author Comment

by:doscar
ID: 1251239
Hey guys, The answer that I was looking for was given by ozo. So I was wandering how would I be able to grade his answer. Now, if ozo doesn't mind I'm willing to grade sganta answer.

 
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question