output question

J

J.D

Hi everyone.

I've been trying to create a simple program that would allow the user
to see an updated set of values without having newline after newline.

For example:

Value: 4 // the 4 could be replaced in the same position
with another
number and so on.

I've been playing around with sprintf and I've gotten good results
with:


/* Placed in a loop with a time delay. Values are updated in the same
line
*/
sprintf(buff, "\r Cpu 0 Temp: %.2f C Cpu 1 Temp: %.2f C Sys Temp:
%.2f C ", t, t1, t2);

cout << buff;


However, when i add a second row:

Cpu 0 Temp: 30 C Cpu 1 Temp: 31 C Sys Temp: 30 C
HD Size: 20 G

my solution no longer works.


Any help would be appreciated.

Thanks
 
P

Phlip

J.D said:
I've been trying to create a simple program that would allow the user
to see an updated set of values without having newline after newline.

You are asking how to reposition your console's cursor. This newsgroup is
not qualified to answer; you'd get better results using
http://groups.google.com , and seeking either "ANSI escape sequences" or
"wincon.h".
 
M

Minti

Hi everyone.

I've been trying to create a simple program that would allow the user
to see an updated set of values without having newline after newline.

For example:

Value: 4 // the 4 could be replaced in the same position
with another
number and so on.

I've been playing around with sprintf and I've gotten good results
with:


/* Placed in a loop with a time delay. Values are updated in the same
line
*/
sprintf(buff, "\r Cpu 0 Temp: %.2f C Cpu 1 Temp: %.2f C Sys Temp:
%.2f C ", t, t1, t2);

cout << buff;


However, when i add a second row:

Cpu 0 Temp: 30 C Cpu 1 Temp: 31 C Sys Temp: 30 C
HD Size: 20 G

my solution no longer works.


Any help would be appreciated.

Thanks


You can't do it using ANSI C++. You would need to refer to your C++
library and see if it provides any functions, like gotoxy() etc.
 
J

J.D

You can't do it using ANSI C++. You would need to refer to your C++
library and see if it provides any functions, like gotoxy() etc.


Thanks for the heads up on gotoxy(), helped me find what i needed.


#include <graph.h>

_settextposition();


Seems to be able to do the trick, works in open watcom 1.2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top