Connecting Tech Pros Worldwide Help | Site Map

output question

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 04:39 PM
J.D
Guest
 
Posts: n/a
Default output question

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

  #2  
Old July 22nd, 2005, 04:39 PM
Phlip
Guest
 
Posts: n/a
Default Re: [OT] 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


  #3  
Old July 22nd, 2005, 04:39 PM
Minti
Guest
 
Posts: n/a
Default 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@
  #4  
Old July 22nd, 2005, 04:42 PM
J.D
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.