Results 1 to 4 of 4

Thread: updating during loops

  1. #1

    Thread Starter
    Addicted Member jmiller's Avatar
    Join Date
    Jul 2002
    Location
    University of Michigan
    Posts
    238

    updating during loops

    Im trying to print some characters on a timed loop(using GetTickCount), and i want 1 to be printed every 10 ms. But the problem is that it prints a bunch of characters over an interval larger than 10 ms. It seems not to be updating at each loop. Is there like a DoEvents statement, like in VB?
    thanks

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's buffering, and there's an easy way to fix it. Are you using C or C++?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    You force the buffer to flush after you place something in it.
    Otherwise the character(s) stay parked in the buffer, and get put to the screen in big blobs.

    In C you can use fflush() --

    Code:
    putc(ch,stdout);
    fflush(stdout);

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Or for C++, use cout << flush;
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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