Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>strftime() format time for string output</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strftime()              Format Time for String Output

 #include   <string.h>                   Required for declarations only

 size_t _cdecl strftime(s1, maxsize, fmt, t1);
 char *s1;              Target string
 size_t maxsize;        Maximum length of string
 const char *fmt;       Format string.
 const struct tm *t1;   Time to convert

        The strftime() function formats the time in t1 according to
        format string fmt and places it into string s1, which is up
        to maxsize characters long.

       Returns:     Number of characters placed in string s1. On error,
                    this number is 0.

   -------------------------------- Example ---------------------------------

 #include <stdio.h>
 #include <dos.h>
 #include <time.h>

 int main(void)

    struct tm *this_time;
    time_t this_secs;
    char s1[50];

    time(&this_secs);
    this_time = localtime(&this_secs);
    strftime(s1, 50, "%M minutes, %I hours, %Z, %A, %B %d 19%y", this_time);
    printf("%s\n", s1);
    return 0;


See Also: mktime() time()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson