Flashing the output to the screen for a limited time

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 12
Reputation: ronjustincase is an unknown quantity at this point 
Solved Threads: 2
ronjustincase ronjustincase is offline Offline
Newbie Poster

Flashing the output to the screen for a limited time

 
0
  #1
Jan 18th, 2009
hi you all..

i want to flash the output message to the screen for a limited time. can you plz help me ?

is there something in iomanip, or should i do something with system("pause") and system("clear").. although the latest dont seem to me like a good solution ..
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,430
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 118
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: Flashing the output to the screen for a limited time

 
0
  #2
Jan 18th, 2009
Look up the Sleep function to use as a delay for the message. To clear the screan, you can either use the "system("cls"), or better, do it manually:
  1. void Clear() {
  2. DWORD n;
  3. DWORD size;
  4. COORD coord = {0};
  5. CONSOLE_SCREEN_BUFFER_INFO csbi;
  6.  
  7. HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
  8.  
  9. GetConsoleScreenBufferInfo ( h, &csbi );
  10.  
  11. size = csbi.dwSize.X * csbi.dwSize.Y;
  12.  
  13. FillConsoleOutputCharacter ( h, TEXT ( ' ' ), size, coord, &n );
  14. GetConsoleScreenBufferInfo ( h, &csbi );
  15. FillConsoleOutputAttribute ( h, csbi.wAttributes, size, coord, &n );
  16.  
  17. SetConsoleCursorPosition ( h, coord );
  18. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 12
Reputation: ronjustincase is an unknown quantity at this point 
Solved Threads: 2
ronjustincase ronjustincase is offline Offline
Newbie Poster

Re: Flashing the output to the screen for a limited time

 
0
  #3
Jan 18th, 2009
ok, the first thing works, e.g.

  1. for(int i=0; i<10; i++) {
  2. cout << i;
  3. sleep(3);
  4. system("clear");
  5. }

but have no understanding on your second soluction. Is there a lib that should i use;

thanks for your reply
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,430
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 118
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: Flashing the output to the screen for a limited time

 
0
  #4
Jan 18th, 2009
That is a windows only solution to clearing the screen, if you're using linux, you should either use system("clear") or use a portable library like ncurses.
Last edited by William Hemsworth; Jan 18th, 2009 at 4:13 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 12
Reputation: ronjustincase is an unknown quantity at this point 
Solved Threads: 2
ronjustincase ronjustincase is offline Offline
Newbie Poster

Re: Flashing the output to the screen for a limited time

 
0
  #5
Jan 19th, 2009
i am with opensuse 11 and system("clear") works
(system("pause")) donot work)

anyway thank you very much for your reply.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 357
Reputation: death_oclock will become famous soon enough death_oclock will become famous soon enough 
Solved Threads: 37
death_oclock's Avatar
death_oclock death_oclock is offline Offline
Posting Whiz

Re: Flashing the output to the screen for a limited time

 
0
  #6
Jan 19th, 2009
Using system() commands is not a good idea, and windows specific functions are not a great solution either. You can use Clock() instead of sleep. Also, check out these special control characters as a way of clearing the screen.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC