473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Screen Handling

I was looking at methods of clearing the screen. I remember using
clrscr() in C on a Unix machine when I was at the institute learning
software development. I tried using it on MS VC++ 6.0. It didn't work.
I looked up the documentation. The documentation said this is a
non-standard function and is included in conio.h. I had included
conio.h already, and yet it couldn't link. I guess clrscr is a unix
thing then?

I also found this code in a book as well as on the Net about clearing
the screen:

THIS CAME FROM A DOWNLOADED SAMPLE
printf("\033[2J"); /* Clear the entire screen. */
printf("\033[0;0f"); /* Move cursor to the top left hand corner */

THIS CAME FROM A BOOK
printf("\x1B[2J");
I also found some documentation saying there was this library called
curses that was very interesting and it dealt with screen handling
functions. I looked it up on Google and found the documentation for
the header curses.h and an overview. But I think I'll also need the
DLL along with the header, so I can use the curses.

My questions are:

(1) Why is it that the phrase "\x1B[2J" should cause the screen to
clear?

(2) Why doesn't it work for me?

(3) Where can I get the necessary files to use curses? Where can I get
some tutorial on using curses, because I saw there was no function to
create a window/console, but there were functions for manipulating
windows (example colorwindow etc.) and they all expected a WINDOW data
type (that's no problem, that's declared in the header, but how do I
fetch a window's. Should I just use the Win32 API GetWindow etc?
Surely, it wouldn't be a Win32 platform specific library - this
curses?).
Nov 14 '05 #1
4 4505
Curious Student wrote:
I was looking at methods of clearing the screen. I remember using
clrscr() in C on a Unix machine when I was at the institute learning
software development. I tried using it on MS VC++ 6.0. It didn't work.
I looked up the documentation. The documentation said this is a
non-standard function and is included in conio.h. I had included
conio.h already, and yet it couldn't link. I guess clrscr is a unix
thing then?

I also found this code in a book as well as on the Net about clearing
the screen:

THIS CAME FROM A DOWNLOADED SAMPLE
printf("\033[2J"); /* Clear the entire screen. */
printf("\033[0;0f"); /* Move cursor to the top left hand corner */

THIS CAME FROM A BOOK
printf("\x1B[2J");
I also found some documentation saying there was this library called
curses that was very interesting and it dealt with screen handling
functions. I looked it up on Google and found the documentation for
the header curses.h and an overview. But I think I'll also need the
DLL along with the header, so I can use the curses. Congradulations, you have found out why clearing the screen is not
part of the standard language (and thus not discussed in this
newsgroup). However, it _is_ a FAQ:
http://www.eskimo.com/~scs/c-faq/q19.4.html

My questions are:

(1) Why is it that the phrase "\x1B[2J" should cause the screen to
clear? Because that is a command for a terminal that supports the
ANSI terminal escape sequences. Different terminals have different
commands to clear the screen. This is what the "curses" library
is based on.


(2) Why doesn't it work for me? You are probably working with a terminal / window that doesn't
support the ANSI escape sequences.


(3) Where can I get the necessary files to use curses? http://www.google.com
http://www.fsf.org
http://www.sourceforge.org

Where can I get some tutorial on using curses, because I saw
there was no function to
create a window/console, but there were functions for manipulating
windows (example colorwindow etc.) and they all expected a WINDOW data
type (that's no problem, that's declared in the header, but how do I
fetch a window's. Should I just use the Win32 API GetWindow etc?
Surely, it wouldn't be a Win32 platform specific library - this
curses?).

http://www.google.com, use "curses tutorial".
Perhaps a good book about the Unix operating system.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #2
In <c5**************************@posting.google.com > es*********@rediffmail.com (Curious Student) writes:
I was looking at methods of clearing the screen.


And you have missed the first reference document you have to read *before*
posting here: the comp.lang.c FAQ.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #3
"Curious Student" <es*********@rediffmail.com> wrote

I was looking at methods of clearing the screen. I remember using
clrscr() in C on a Unix machine when I was at the institute learning
software development.

Unfortunately there are no ANSI C functions for manipulating the display.
You receive characters from stdin, and send characters to stdout. If you
want to clear the screen, print green text, suppress echoing to input a
password, you must use a platform-specific library.
Nov 14 '05 #4
"Malcolm" <ma*****@55bank.freeserve.co.uk> writes:
"Curious Student" <es*********@rediffmail.com> wrote
I was looking at methods of clearing the screen. I remember using
clrscr() in C on a Unix machine when I was at the institute learning
software development.

Unfortunately there are no ANSI C functions for manipulating the display.
You receive characters from stdin, and send characters to stdout. If you
want to clear the screen, print green text, suppress echoing to input a
password, you must use a platform-specific library.


<QUIBBLE>

You must write platform-specific code. It may not be necessary to
use a platform-specific library (though that's usually the best
way to do it). For example, the following program:

#include <stdio.h>
int main(void)
{
fputs("\033[1;1H\033[2J", stdout);
return 0;
}

*might* clear the screen on your system (it does on mine); if so, it
does so without using any platform-specific library.

The advantage of using a platform-specific library, of course, is that
you don't have to reinvent the wheel.

</QUIBBLE>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
48
by: David J Patrick | last post by:
I'm trying to rewrite the CSS used in http://s92415866.onlinehome.us/files/ScreenplayCSSv2.html. using the w3.org paged media standards as described at http://www.w3.org/TR/REC-CSS2/page.html ...
5
by: Patrick De Ridder | last post by:
My program produces a number of overviews, for which I use different forms, which are displayed. These forms are displayed at certain positions on the screen. I don't want the user of the program...
11
by: K E Senthil Kumar | last post by:
Hi, I have created an application which uses a SQL server database. I created a mainform which retreives all the customers. This takes about 3sec. I have created a splash screen too. I use a...
0
by: Jeffery Tyree | last post by:
I have a machine that will be used to demo some Excel spreadsheets at a convention. Because I did not author the spreadsheets and attendees will be allowed to play with the spreadsheets, I needed...
2
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and something I've had on my mind for awhile is to make a little "virtual console screen" class structure. In it I want to be able to do "text animation" - moving...
1
by: coursemat | last post by:
Hi, I need some help...Plz be patient and read it --i guess one cant get more confusing than this 1 I have a set of screens .... Screen1. A search screen - to search for a list of customers...
5
by: iKiLL | last post by:
Hi All I am new to Windows Mobile Development and I was hoping to get some advice on the best way to handle Screen size and cut copy and past. I am developing with VS2005 for Windows...
1
by: Allen | last post by:
How to force System.Windows.Forms.Screen.AllScreens to update when attaching an additional monitor? Form1 is Loaded and runs the following upon detection of additional monitor: Dim Screens()...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.