On Tue, 11 Nov 2003 19:14:34 -0500, James Leddy
<jl*****@binghamton.edu> wrote in comp.lang.c:
Hello,
I need to write a program that will flash random numbers in the first line
of output. The first number flashed will only remain on the screen for
about 10 milliseconds. Then another number should appear in the same place
190 milliseconds later. I don't know how to approach the problem of
putting the standard output buffer back to the first point of output to
overwrite the number. I tried using fseek() on the standard output, but it
returned -1
I know that this can be accomplished. I just need a little bit of guidance.
Thanks for your help
Not all files are seekable, particularly not those connected to
interactive, live human interface devices.
You could try something like:
fputs("string with first number", stdout);
....then to erase:
fputs("\r \r", stdout);
....where the second string has enough ' ' characters to overwrite the
first number, and whenever you are ready:
fputs("string with second number", stdout);
Might or might not work, depends greatly on your OS and terminal
driver.
You could replace the fputs() calls with printf() without a '\n', but
not puts(), which appends a newline automatically and moves to another
terminal display row, from whence there is no standard C method to
return.
You might also ask in a platform specific group, your compiler/OS
might provide its own extensions to make this easier.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
ftp://snurse-l.org/pub/acllc-c++/faq