954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Selective clearing of Console Window

Is there anyway we can clear only a selected part of the console window?
clrscr() from conio.h & system("CLS") clears the whole screen.
So how to clear screen selectively?


For example, one of my old code prints this,
Enter the limit for the array size (Max: 20)
10

Enter the elements for the array
1
2
3
4
5
6
7
8
9
10


The greatest interger is 10
The smallest integer is 1

But i want it to be like this, just after the user enters the last element. Enter the limit for the array size (Max: 20)
10



The greatest interger is 10
The smallest integer is 1

Captain Jake
Posting Whiz in Training
209 posts since Nov 2011
Reputation Points: 12
Solved Threads: 11
 

may be u can use a loop of cout<

lohath
Newbie Poster
3 posts since Dec 2011
Reputation Points: 10
Solved Threads: 1
 

Depending on which version of C++ you're using...
Borland will allow you to easily set the cursor position and then overwrite what you need.
You can also just KEEP all of the data in an array or list and rewrite just the part you want when the screen is fully cleared.

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

may be u can use a loop of cout<

But how do you think i can go to a previous line? Any Idea? Thanks for the post...

Captain Jake
Posting Whiz in Training
209 posts since Nov 2011
Reputation Points: 12
Solved Threads: 11
 
Depending on which version of C++ you're using... Borland will allow you to easily set the cursor position and then overwrite what you need. You can also just KEEP all of the data in an array or list and rewrite just the part you want when the screen is fully cleared.

Well i am using Microsoft Visual C++ 2010 Express edition, but to my surprise, it have all the Turbo C++ exclusive header files, like conio.h, math.h (I presume, we use cmath in modern compilers) etc etc etc.....Not sure, this is because i installed VC++, even though i had TC++ installed....

Well back to the topic, How can i set the cursor position in TC++? And how to get the coordinates of cursor position. Please show me an example, that would be very kind of you.

Captain Jake
Posting Whiz in Training
209 posts since Nov 2011
Reputation Points: 12
Solved Threads: 11
 

Here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682022(v=VS.85).aspx

Disregard the first example and scroll down to see proper handling of a Windows console.

MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
 

Here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682022(v=VS.85).aspx

Disregard the first example and scroll down to see proper handling of a Windows console.

Would that let me delete part of the console, which have already been printed? Asked because i found it little hard to understand. And can you help me with how to find the mouse coordinates to be assigned in that example? Thanks for the help...

Captain Jake
Posting Whiz in Training
209 posts since Nov 2011
Reputation Points: 12
Solved Threads: 11
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: