Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



C : Implementation of ctime()

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 01-02-2010
Member
 
Join Date: Dec 2009
Posts: 31
C : Implementation of ctime()
  

Hello, I am the student of the MCA first year. I had learn the C language in the BscIT. I know about some of the header files of the C language. So, I want to know about the ctime() function. I also want to know about the what is actual use of the ctime() function, How ctime() function works, and How can I implement the ctime() function in the C language. If anyone has the any idea about the ctime() function, so Please reply me.

Reply With Quote
  #2  
Old 01-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,944
Implementation of ctime()

Hi, The calendar time that is pointed to by timer to the local time can be converted by the ctime() function basically in the form of string consisting of 26 characters exactly. Example of this string can be shown in form of the following :
Sun Feb 22 15:58:27 1988\n\0
The syntax of the ctime() function can be as follows :
#include <time.h>
char *_ctime( const time_t *timer, char *buf );
Reply With Quote
  #3  
Old 01-02-2010
Member
 
Join Date: May 2008
Posts: 2,001
Re: C : Implementation of ctime()

I guess you should understood from the following explanation. If the ctime() function is an ANSI function then it places the resultant string in a static buffer that can be used again every time whenever the ctime() function can be called. If the ctime() function is an NON-ANSI function then it places the resultant string in the buffer that can be pointed to by buf. The tzset() function can also be called whenever the ctime() function is being called.
Reply With Quote
  #4  
Old 01-02-2010
Member
 
Join Date: Apr 2008
Posts: 1,993
C : Implementation of ctime()

The following sample program helps you to understand ctime() function more easily :
#include <stdio.h>
#include <time.h>
void main()
{
time_t timfdy;
char bf[26];
timfdy = time( NULL );
printf( " It is now: %s ",
ctime( &timfdy, bf ) );
}
The output of the above program can be :
It is now: Sat jan 25 15:58:42 1988
Reply With Quote
  #5  
Old 01-02-2010
Member
 
Join Date: May 2008
Posts: 2,283
Re: C : Implementation of ctime()

By using the time() function the calender time can be obtained. That calender time can be generally Co-ordinated Universal Time. This UTC can be known as the GMT that means Greenwich Mean Time. The time set on the computer with the QNX date command reflects Coordinated Universal Time. The environment variable that is TZ can be used to established the local time zone.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "C : Implementation of ctime()"
Thread Thread Starter Forum Replies Last Post
Finding ctime,mtime and atime John Wilson Operating Systems 5 12-03-2010 08:13 PM
Implementation of mkfifo() : C Garett Software Development 4 02-02-2010 06:27 PM
Implementation of mkdir() : C Agustíne Software Development 4 02-02-2010 05:16 PM
C : Implementation of sin(),pow(),sqrt() Adolfa Software Development 4 30-01-2010 11:41 AM
How to convert CString to CTime Heather5 Software Development 3 03-09-2009 09:13 PM


All times are GMT +5.5. The time now is 05:37 AM.