Results 1 to 3 of 3

Thread: No leading zero's when outputting tim

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222

    No leading zero's when outputting tim

    I am outputting time in this format:

    KeyDOWN:16,Thu Jan 03 16:33:51.284 2002

    but on certain lines where it outputs the seconds.milliseconds the leading zero..if there is one is sometimes removed! e.g.

    it will output: 16:33:51.23
    when it should really be: 16:33:51.023

    this makes it difficult for me later ....why would it be doing this?

    This is the timing code that i am using:
    //Global
    /*Timer Elements*/
    struct _timeb timebuffer;
    char *timeline;


    //In the function

    //Timer Elements
    _ftime( &timebuffer );
    timeline = ctime( & ( timebuffer.time ) );




    fprintf(pKB, "KeyUP:%d,%.19s.%hu %s",wParam,timeline, timebuffer.millitm, &timeline[20] );

    am i doing something wrong?!?!? or is there another way?

    cheers in advance for any insite into this!

    Andy

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    try:
    fprintf(pKB, "KeyUP:%d,%.19s.%3hu %s",wParam,timeline, timebuffer.millitm, &timeline[20] );
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    UK
    Posts
    222
    that works but dosen't put in the zero's just spaces!?
    e.g.:

    KeyUP:70,Sat Jan 12 12:08:03. 3 2002
    KeyUP:72,Sat Jan 12 12:08:03. 53 2002


    is there a way of making it put zero's instead of spaces!?

    cheers again

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width