gmtime() - I/O Function

How is "gmtime()" used in C++?
How to return a pointer?

Explanation

gmtime() is an I/O function that returns a pointer in the "tm" format with individual or broken time format. The time is represented in Coordinated Universal Time (UTC)which will be GMT(Greenwich Mean Time). The time is obtained by calling the "time()" function. A "NULL" is returned if the system does not support GMT.
The formatted output string returned by this function is stored in a static character array. This array is overwritten each time the function is called.

Syntax:


struct tm *gmtime( const time_t * time );

Example :



#include <stdio.h>
#include <time.h>
void main( )
{
struct tm *ptr;
long cutc;
time( &cutc );
ptr = gmtime( &cutc );
printf( "Coordinated universal time is::
%s\n",asctime( ptr ) ); }

Result :

Coordinated universal time is:: Mon Mar 08 16:05:10 2010

The formatted output string returned by this function is stored in a static character array. This array is overwritten each time the function is called.

C++ Tutorial


Ask Questions

Ask Question