codescracker


c

C ctime()



« Previous Function Next Function »


ctime()

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 :

#include<time.h>
char *ctime(const time_t *time);

ctime() Example

Following program displays the local time defined by the system :

#include<time.h>
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	time_t lt;
	lt = time(NULL);
	printf(ctime(&lt));
	getch();
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test