LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-28-2003, 04:22 PM   #1
qcoder
Member
 
Registered: Oct 2003
Location: United States
Distribution: Debian
Posts: 65

Rep: Reputation: 15
Question Clearing the screen in C++


I would like to know how to clear the screen in C++. I don't want to have to use system("clear") because I want to be able to have my programs work in windows too.
 
Old 11-29-2003, 01:40 AM   #2
yarnar
LQ Newbie
 
Registered: Nov 2003
Location: Bangalore,India.
Posts: 20

Rep: Reputation: 0
clrscr();
???
 
Old 11-29-2003, 01:53 AM   #3
shellcode
Member
 
Registered: May 2003
Location: Beverly Hills
Distribution: Slackware, Gentoo
Posts: 350

Rep: Reputation: 31
Code:
void clear(void)
{
    printf("\033[2J\033[0;0f");
}
in case you dont want to use clrscr because that requirese ncurses.
 
Old 11-29-2003, 10:35 AM   #4
scottpioso
Member
 
Registered: Jan 2003
Location: United States of America and damn proud of it!
Distribution: Ubuntu
Posts: 466

Rep: Reputation: 30
Couldn't you just assign an alias to shorten that for you?
 
Old 11-29-2003, 11:01 AM   #5
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
Quote:
Originally posted by scottpioso
Couldn't you just assign an alias to shorten that for you?
If you mean a #define instead of an inline method, then the inline method is recommended in C++ (and as efficient).

Regards
Martin
 
Old 11-29-2003, 11:16 AM   #6
scottpioso
Member
 
Registered: Jan 2003
Location: United States of America and damn proud of it!
Distribution: Ubuntu
Posts: 466

Rep: Reputation: 30
Hi,

I really don't know much more than what I remember from my Unix basics class. What we did was create aliases so that we could execute a command using a shortcut and your clearing example made me think of that. I remember the normal syntax for clearing a screen was clear, but we made an alias to do it by just typing cl. Hope this makes sense.
 
Old 11-29-2003, 11:51 AM   #7
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
You're probably talking about terminal commands. (Similar to what you write at a good ol' DOS prompt.)

The question here was about clearing the screen from inside a C++ program.

Regards
Martin
 
Old 11-29-2003, 12:03 PM   #8
scottpioso
Member
 
Registered: Jan 2003
Location: United States of America and damn proud of it!
Distribution: Ubuntu
Posts: 466

Rep: Reputation: 30
Yes, I'm sorry, I thought that was what you wanted. My fault.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Angry Help clearing the panel at the boto of the screen (where the aps, desktop, web A6Quattro Fedora 2 10-16-2005 11:53 PM
Help clearing the panel at the boto of the screen (where the aps, desktop, web browse A6Quattro Suse/Novell 2 10-16-2005 11:17 PM
Clearing the tty console screen on logout koyi Linux - General 8 07-30-2004 12:32 PM
Clearing the Ms Dos screen in java? Ginger1329 Programming 3 11-13-2003 10:40 PM
Clearing screen xunilpassion Programming 1 10-16-2003 04:54 PM


All times are GMT -5. The time now is 08:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration