|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I am using GCC on FEDORA.
I want to print current date an time. How can do that. Thanks -Sanchit |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 14 Apr 2008 at 17:14, Sanchit wrote:
> I am using GCC on FEDORA. > > I want to print current date an time. How can do that. system("date"); |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote:
> On 14 Apr 2008 at 17:14, Sanchit wrote: > > > I am using GCC on FEDORA. > > > I want to print current date an time. How can do that. > > system("date"); Oh I forgot to mention.. I want a C function for this. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 14 Apr 2008 at 17:39, Sanchit wrote:
> On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote: >> On 14 Apr 2008 at 17:14, Sanchit wrote: >> >> > I am using GCC on FEDORA. >> >> > I want to print current date an time. How can do that. >> >> system("date"); > > Oh I forgot to mention.. I want a C function for this. strftime? |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 14 Apr, 19:14, Sanchit <sanchitgupt...@gmail.com> wrote:
> I am using GCC on FEDORA. > > I want to print current date an time. How can do that. #include <time.h> #include <stdio.h> #include <stdlib.h> int main(){ time_t now = time(NULL); struct tm *now_s = localtime(&now); if(now_s == NULL) return EXIT_FAILURE; printf("%d-%02d-%02d %02d:%02d:%02d\n", 1900+now_s->tm_year, ++now_s - >tm_mon, now_s->tm_mday, now_s->tm_hour, now_s->tm_min,now_s->tm_sec); return EXIT_SUCCESS; } Bye. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
>I am using GCC on FEDORA.
> >I want to print current date an time. How can do that. In C, time() gets you the current date/time in a time_t format. Various functions can get that into a printable string format: ctime() localtime() followed by strftime() localtime() followed by asctime() |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Apr 14, 10:39 pm, Sanchit <sanchitgupt...@gmail.com> wrote:
> On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote: > > > On 14 Apr 2008 at 17:14, Sanchit wrote: > > > > I am using GCC on FEDORA. > > > > I want to print current date an time. How can do that. > > > system("date"); > > Oh I forgot to mention.. I want a C function for this. http://www.cs.utah.edu/dept/old/texi...19.html#SEC320 |
|
![]() |
| Outils de la discussion | |
|
|