clear screen


 
Thread Tools Search this Thread
Top Forums Programming clear screen
# 1  
Old 07-31-2002
Question clear screen

what is the syntax for clearing the screen in c ?
when i tried "Clrscr()" the CC complier does not reconise it.
please do tell me more about this.
thanking you

imma
# 2  
Old 07-31-2002
yes clrscr() works for me. I tried using curces.h

#include <curses.h>

void clrscr()
{

in the end of your code use

clear();
refresh();
}
# 3  
Old 08-01-2002
Quote:
Originally posted by killerserv
yes clrscr() works for me. I tried using curces.h

#include <curses.h>

void clrscr()
{

in the end of your code use

clear();
refresh();
}
Is there any compiler argument that has to been entered when compiling to invoke those funktions?

I only got a SEGfault with gcc.

clear(); does not clear the screen.
and I cant compile with refresh(); in the code.

I'm kind of new in c programming to so excuse my question.
But I'm learning Smilie

Thanks!
# 4  
Old 08-01-2002
Curses is a subsystem (library) for managing character screens. Using it involves more than just calling the clear-screen function. You have to initialize it, etc.

From your question, it isn't clear to me that you are using Curses. If you want to, that's a study in itself, and there are several books on the subject, and probably some tutorials you can find on the web.

Aside from Curses, there is no standard way to clear the screen, or even to treat the terminal AS a screen. Standard C assume that the terminal is a line-at-a-time device.
Marc Rochkind
# 5  
Old 08-01-2002
Try this:

Code:
#include <curses.h>

int  main(void)
{
     initscr();
     clear();
     refresh();
     endwin();
}

And compile with:
cc prog.c -o prog -lcurses
# 6  
Old 08-02-2002
Quote:
Originally posted by hell666
Try this:

Code:
#include <curses.h>

int  main(void)
{
     initscr();
     clear();
     refresh();
     endwin();
}

And compile with:
cc prog.c -o prog -lcurses
Ok, thanks!
There is an other way else with:
#include <stdlib.h>
int main(void)
{
system("clear");
}

but there is allways fun to explorer new ways in doing things Smilie
I will go straight home now and read the manpages inside and out Smilie

later!
# 7  
Old 08-02-2002
well its great to read all this ...sometimes its really wonderfull
to know the diffrent algrorithm or approach for a simple progam
or commands ...which we often use it.


imma
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clear specific part of the screen

I want to clear specific part of the screen. Say for example , i am running a bash script for i in {1..100} do echo "Current Record = $i" done if i use a clear command over there , it will clear my screen however when i scroll up i would have the old records , is there anyway in unix to... (5 Replies)
Discussion started by: chidori
5 Replies

2. UNIX for Dummies Questions & Answers

Accidentally made a screen within a screen - how to move it up one level?

I made a screen within a screen. Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies

3. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

4. Shell Programming and Scripting

Clear Screen Command for BASH shell

I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands. I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as alias cls='^L' This is how i defined other aliases ... (4 Replies)
Discussion started by: erora
4 Replies

5. OS X (Apple)

Virtual screen accessed by Screen Sharing

Hi, I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it. The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies

6. UNIX for Dummies Questions & Answers

how to clear history

Hi... i have one doubt pls... 1)can we clear the command line history in UNIX for a paricular login(scadm/root)if so how?. 2) can we see the time at which command executed. history is showing like : 100 display 101 lock 102 exit (7 Replies)
Discussion started by: gincemathew
7 Replies

7. Programming

how to clear screen in GDB session

hi , Could any one tell me the command for clearing the screen in GDB session (1 Reply)
Discussion started by: useless79
1 Replies

8. Shell Programming and Scripting

Clear screen in NAWK

Hello guys, I wonder if it is possible to clear out the screen in AWK. I'm printing out mail messages and I would like every message starting on the beginning of the screen. When I use FOR loop and printf("\n") it clears out the screen but my text is somewhere in the middle of the screen. ... (2 Replies)
Discussion started by: petoSVK
2 Replies

9. Programming

clear screen in g++

How do I clear screen in g++ I've included curses and tried compile with lcurses as per gcc but fails, I can clear by using system("clear") but would prefer to use the curses library if possible. (2 Replies)
Discussion started by: gefa
2 Replies

10. Programming

How to clear screen

I searched the post and someone said to clear the screen in C, use printf("\033[2J"); ?? However, this doesn't work...typo or no. What is an equivalent command to 'CLS' in DOS/'clear' in UNIX to clear the screen and go to top of screen?? Thank you. (2 Replies)
Discussion started by: giannicello
2 Replies
Login or Register to Ask a Question