C ctime()

« Previous Function Next Function »


The ctime() function returns a pointer to a string of the form

day month year hours:minutes:seconds year\n\0

given a pointer to the calendar time. The calendar time is often obtained through a call to time().

The buffer used by ctime() to hold the formatted output string is a statically allocated character array and is overwritten each time the function is called. If you wish to save to contents of the string, it is necessary to copy it elsewhere.

ctime() Syntax

Following is the syntax of the ctime() function :

char *ctime(const time_t *time);

ctime() Example

Following program displays the local time defined by the system :

void main()
	time_t lt;
	lt = time(NULL);

« Previous Function Next Function »