Connecting Tech Pros Worldwide Help | Site Map

output question

J.D
Guest
 
Posts: n/a
#1: Jul 22 '05
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
Phlip
Guest
 
Posts: n/a
#2: Jul 22 '05

re: output question


J.D wrote:
[color=blue]
> 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.[/color]

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".

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


Minti
Guest
 
Posts: n/a
#3: Jul 22 '05

re: output question


ynotoriginal1@yahoo.com (J.D) wrote in message news:<a296a119.0407191452.7ff305f9@posting.google. com>...[color=blue]
> 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[/color]


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.

--
Imanpreet Singh Arora
@isingh@ AT @ACM@ DOT @ORG@
J.D
Guest
 
Posts: n/a
#4: Jul 22 '05

re: output question


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


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
Closed Thread