It is sometimes useful to display the current date in your terminal.
For that the time() system call function is the best one.
Let's see an example within this tiny tutorial of C programming language:
// main.c
#include <time.h>
#include <stdio.h>
int main () {
time_t myTime;
time(&myTime);
printf("The time is: %s", ctime(&myTime));
return 0;
}Compiling and executing.
And the result is:
$ The time is: Wed Feb 22 14:36:43 2012
All simply! ![]()
© Badprog - I want to change the world. And I will.
Add new comment