codescracker


c

C asctime()



« Previous Function Next Function »


asctime()

The asctime() function returns a pointer to a string that contains the information stored in the structure pointed to by ptr converted into the following form :

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

For example:

Fri Apr 15 12:05:34 2005

The structure pointed to by ptr is usually obtained from either localtime() or gmtime().

The buffer used by asctime() 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 the contents of the string, you must copy it elsewhere.

asctime() Syntax

Following is the syntax of the asctime() function :

#include<time.h>
char *asctime(const struct tm *ptr);

asctime() Example

Following program displays the local time defined by the system :

#include<time.h>
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	struct tm *ptr;
	time_t lt;
	lt = time(NULL);
	ptr = localtime(&lt);
	printf(asctime(ptr));
	getch();
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test