943,522 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 699
  • C++ RSS
Jan 18th, 2009
0

Flashing the output to the screen for a limited time

Expand Post »
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 ..
Reputation Points: 11
Solved Threads: 2
Newbie Poster
ronjustincase is offline Offline
12 posts
since Dec 2008
Jan 18th, 2009
0

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

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:
C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Jan 18th, 2009
0

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

ok, the first thing works, e.g.

C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 11
Solved Threads: 2
Newbie Poster
ronjustincase is offline Offline
12 posts
since Dec 2008
Jan 18th, 2009
0

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

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.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Jan 19th, 2009
0

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

i am with opensuse 11 and system("clear") works
(system("pause")) donot work)

anyway thank you very much for your reply.
Reputation Points: 11
Solved Threads: 2
Newbie Poster
ronjustincase is offline Offline
12 posts
since Dec 2008
Jan 19th, 2009
0

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

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.
Reputation Points: 128
Solved Threads: 43
Posting Whiz
death_oclock is offline Offline
389 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: simple text editor
Next Thread in C++ Forum Timeline: Creation of an application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC