Forum     

Go Back   Digit Technology Discussion Forum > Software > Open Source
Register FAQ Calendar Mark Forums Read

Open Source A place where you can talk to like-minded people about the fastest growing software movement today! Discuss anything and everything about Open Source software and Operating Systems.


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 03-02-2009, 07:54 AM   #1 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,490
Exclamation C & C++ getch() and clrscr() functions in Linux


Hope this helps newbies.

clrscr()
Code:
system("clear");      //Needs cstdlib headder file so do #include<cstdlib>
getch()
Code:
getchar();            // Needs stdio.h so do #include<stdio.h>
And yeah, always use
Code:
using namespace std;
after including headders. Need that because actual usage of cout otherwise is std::cout and not cout, and so on.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is online now  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 03-02-2009, 08:12 AM   #2 (permalink)
Wahahaha~!
 
Faun's Avatar
 
Join Date: Dec 2006
Location: Pune/there
Posts: 7,676
Default Re: C & C++ getch() and clrscr() functions in Linux

that system call will cost you jackpot
__________________
Blog | Flickr | Battlelog
Spoiler:
Asus Z68 V-Pro|i5 2500k|TRUE Black|Ripjaws X|U2311H|N560GTX|D7000|XONAR STX|RE272|RE0|CC51|XE200PRO Walnut| TD II V2| Ultraphile|N5800

Mono
Faun is offline  
Old 03-02-2009, 09:00 AM   #3 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,490
Default Re: C & C++ getch() and clrscr() functions in Linux

Quote:
Originally Posted by T159 View Post
that system call will cost you jackpot
why ?
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is online now  
Old 03-02-2009, 06:31 PM   #4 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: C & C++ getch() and clrscr() functions in Linux

system("clear") is NOT exactly same as clrscr() and gives a warning when I try it.
abc.c:7: warning: implicit declaration of function ‘system’
abc.c:8: warning: control reaches end of non-void function


(you can avoid the first warning by stdlib.h but the second one stays)

Also I think, Linux users don't need a clrscr() 'coz:
(1) It will not go according to usual conventions used. For instance there are no terminal programs I have used which actually clear the space.
(2) Newbies or even amateurs who generally want to program in Linux should use Geany. It's excellent.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline  
Old 04-02-2009, 02:21 PM   #5 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,490
Default Re: C & C++ getch() and clrscr() functions in Linux

^Fully agree, though I don't get the errors.

1. Yup. We guys don't like it when a program abruptly clears the valuble output.

2. WTH ? Geany ? How does the IDE have any thing to do with a function ?


Anyway, I posted this because newbies and switches from windows may need something to make their windows apps compatible with linux.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is online now  
Old 04-02-2009, 02:25 PM   #6 (permalink)
damnbadman666
 
damngoodman999's Avatar
 
Join Date: Nov 2008
Location: Coimbatore
Posts: 2,590
Default Re: C & C++ getch() and clrscr() functions in Linux

namespace is not needed !!!
__________________
AMD Phenom 2 940 @ 3.4Ghz [Hyper 212+] :arrow: MA790GP-UD4H :arrow: OCZ DDR2 2x2GB :arrow: Asus GTX 560ti :bananana::arrow: 1TB SATA2 :arrow: LG 20" LED :arrow: Razer DA mice :arrow: RED HOT cabby
damngoodman999 is offline  
Old 04-02-2009, 02:29 PM   #7 (permalink)
The Smaller Bang
 
MetalheadGautham's Avatar
 
Join Date: Sep 2007
Location: Gautham City
Posts: 7,490
Default Re: C & C++ getch() and clrscr() functions in Linux

^^Yes it is. Unless for stuff like cin, cout, etc you replace them with std::cin, std::cout, etc, which is time consuming.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
MetalheadGautham is online now  
Old 12-02-2009, 03:56 PM   #8 (permalink)
Tech Freak
 
josephcs's Avatar
 
Join Date: Jan 2009
Location: 127.0.0.1 / localhost
Posts: 25
Default Re: C & C++ getch() and clrscr() functions in Linux

Thank you dude!! I always had this confusion..!
__________________
AMD Athlon 64 X2 Dual Core 6000+ 3.0GHz - 320 GB SATA - LG & Lite-On DVD Burner - iBall Designer Series Cabinet - Creative SBS A300 - Samsung 19" WideScreen
Techie | Freelancer | Student
josephcs is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use clrscr() function in gcc? ThinkFree Open Source 11 27-08-2008 10:06 PM
How to Use 1 button for 2 functions Chetan1991 QnA (read only) 3 01-09-2007 04:20 PM
About C functions clrscr, delay. Cannot be found? aditya.shevade QnA (read only) 6 25-01-2007 09:45 PM
What are the functions of all these 4 AVG services? Vishal Gupta QnA (read only) 4 09-10-2005 11:26 PM

 
Latest Threads
- by soumya
- by clmlbx
- by Charan
- by Sujeet
- by reddick

Advertisement




All times are GMT +5.5. The time now is 12:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2