C Date and Time Functions - Example

Example

The following C source code snippet prints the current time to the standard output stream.

#include #include #include int main(void) { time_t_current_time; char* c_time_string; /* Obtain current time as seconds elapsed since the Epoch. */ current_time = time(NULL); if (current_time == ((time_t)-1)) { (void) fprintf(stderr, "Failure to compute the current time."); return EXIT_FAILURE; } /* Convert to local time format. */ c_time_string = ctime(&current_time); if (c_time_string == NULL) { (void) fprintf(stderr, "Failure to convert the current time."); return EXIT_FAILURE; } /* Print to stdout. */ (void) printf("Current time is %s", c_time_string); return EXIT_SUCCESS; }

The output is:

Current time is Sun Oct 28 12:30:37 2012

Read more about this topic:  C Date And Time Functions

Other articles related to "example":

Example

Example may also refer to:

  • Example (musician), a British musician
  • Example, Florida rock band For Squirrels' sole major-label album, released in 1995
  • example.com, example.net, example.org, example.edu and .example, domain names reserved for use in documentation as examples
  • HMS Example (P165), an Archer-class patrol and training vessel of the British Royal Navy
  • The Example, a 1634 play by James Shirley
  • The Example (comics), a 2009 graphic novel by Tom Taylor and Colin Wilson
Finite Model Theory - Basic Challenges - Characterisation of A Class of Structures - Example
4 ... Next we have to scale the structures up by increasing m ...
Wave Front Set - Definition - Example
... Then the projection on the first component of a distribution's wave front set is nothing else than its classical singular support, i.e ... the complement of the set on which its restriction would be a smooth function ...

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)