The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to clear screen in GDB session useless79 High Level Programming 1 09-06-2007 07:59 PM
Clear log file in use. coolbhai UNIX for Advanced & Expert Users 10 06-20-2007 06:37 AM
Clear screen in NAWK petoSVK Shell Programming and Scripting 2 05-21-2006 08:01 PM
clear screen in g++ gefa High Level Programming 2 04-22-2006 06:00 AM
How to clear screen giannicello High Level Programming 2 05-14-2002 01:32 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2002
Registered User
 

Join Date: Jul 2002
Posts: 7
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-31-2002
killerserv's Avatar
Unix Predator
 

Join Date: Dec 2000
Location: Phoenix, AZ
Posts: 670
yes clrscr() works for me. I tried using curces.h

#include <curses.h>

void clrscr()
{

in the end of your code use

clear();
refresh();
}
Reply With Quote
  #3 (permalink)  
Old 08-01-2002
Registered User
 

Join Date: Jul 2002
Location: Sweden
Posts: 46
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

Thanks!
Reply With Quote
  #4 (permalink)  
Old 08-01-2002
Marc Rochkind
Guest
 

Posts: n/a
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.
Reply With Quote
  #5 (permalink)  
Old 08-01-2002
Registered User
 

Join Date: Jul 2002
Location: void
Posts: 53
Try this:

Code:
#include <curses.h>

int  main(void)
{
     initscr();
     clear();
     refresh();
     endwin();
}
And compile with:
cc prog.c -o prog -lcurses
Reply With Quote
  #6 (permalink)  
Old 08-02-2002
Registered User
 

Join Date: Jul 2002
Location: Sweden
Posts: 46
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
I will go straight home now and read the manpages inside and out

later!
Reply With Quote
  #7 (permalink)  
Old 08-02-2002
Registered User
 

Join Date: Jul 2002
Posts: 7
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
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0