The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Clearing the screen on a linux system
Discuss Clearing the screen on a linux system in the C Programming forum on Dev Shed. Clearing the screen on a linux system C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 21st, 2002, 01:54 AM
|
|
Junior Member
|
|
Join Date: Jan 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Clearing the screen on a linux system
I am writng a c++ program. In the program I want to clear the screen. How do I do that?
Thanks,
Jonathan Donaghe
URL
|

January 21st, 2002, 07:45 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
What compiler are you using?
I am guessing this is a console application and not a windows application or you wouldn't be asking that question.
If you are using a Borland compiler you can include the conio.h header and use the function clrscr(). I am not sure which boreland compilers that support this function anymore. I know microsoft does not support this. I am not sure, but I don't believe *nix compilers do either.
|

January 21st, 2002, 02:32 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
I'm sorry, I just realized you had Linux in your subject line.
In the case of clearing the screen in a linux app, I don't know of a standard function that does this. If someone else does, I would love to know also. The only method I know of is to print around 21 blank lines to the screen to accomplish this task.
I know there must be different ways to accomplish this though, especially if you are using ncurses.
|

January 22nd, 2002, 12:35 AM
|
|
Junior Member
|
|
Join Date: Jan 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I have found the answer
Thanks for your help. But I have found the way to clear the screen. You can use a function called system() in the <stdlib.h> library. If you are trying to clear the screen in dos you would use:
system("cls")
If you are trying to clear the screen in Linux/Unix you would use:
system("clear")
This function will also call the rest of the system calls.
Thanks,
Jonathan Donaghe
|

January 22nd, 2002, 07:34 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
I know of that, remember trying it once. I believe I ran into some sort of problem with it, just don't remember what.
Glad you found it.
|

January 22nd, 2002, 01:35 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
Onslaught, I think the problem you might be referring to is the return value of the system() call (at least in DOS/Windows versions). The problem is that the system() call will always return 0, even if the program that was executed returns a different value. The *nix version of system() is much better because it returns the value from the program that was executed.
|

January 22nd, 2002, 02:12 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
Actually, if I remember correctly, I can't say for sure, it has been years since I have actually tried to do it, but I believe that it was actually executing the command before I needed it to.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|