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 26-08-2008, 09:19 PM   #1 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,429
Default How to use clrscr() function in gcc?

Is it possible to use functions like clrscr(), gotoxy() in gcc? I have found that conio.h is for windows only, but is there any workaround to be able to use it in linux?
ThinkFree is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 26-08-2008, 09:32 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,657
Default Re: How to use clrscr() function in gcc?

There are alternatives upto a possible-extent available in the ncurses libraries (Only available for POSIX systems). Link has a tutorial too, the basics are easy stuff

There are clear() and move() functions in ncurses that can help.
Code:
man curs_clear
man curs_move
# For more help.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 26-08-2008, 10:18 PM   #3 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
Default Re: How to use clrscr() function in gcc?

or use system("clear"); or system("cls") which don't require any external lib. But thats not a good practice. But it servers the purpose !
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 26-08-2008, 10:28 PM   #4 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,429
Default Re: How to use clrscr() function in gcc?

^
I get the following error using system("clear"); inside main()
error: ‘system’ was not declared in this scope
ThinkFree is offline  
Old 26-08-2008, 10:48 PM   #5 (permalink)
Alpha Geek
 
Krazy_About_Technology's Avatar
 
Join Date: Jun 2004
Location: Noida - India
Posts: 764
Default Re: How to use clrscr() function in gcc?

include stdlib.h in your program.
__________________
Dell Inspiron 1525 - C2D 2 Ghz, 3GB, 250GB, X3100

Samsung Omnia Pro B7610 with Stock WM 6.1 ROM

Blog: http://www.sumitbhardwaj.co.in/blog
Krazy_About_Technology is offline  
Old 26-08-2008, 10:51 PM   #6 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,429
Default Re: How to use clrscr() function in gcc?

^Working now, but it's not clearing the screen.
ThinkFree is offline  
Old 26-08-2008, 10:51 PM   #7 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,657
Default Re: How to use clrscr() function in gcc?

"clear" will not always work cause Linux's method of clearing the terminal is different than Windows and will sometimes give you good WTF moments

system() not being found is very weird indeed, I have clue on this, but try including <stdlib.h> or <cstdlib> if C++...
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 26-08-2008, 10:53 PM   #8 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,429
Default Re: How to use clrscr() function in gcc?

No error given be compiler with stdlib but still not clearing the screen.

Quote:
system() not being found is very weird indeed, I have clue on this, but try including <stdlib.h> or <cstdlib> if C++...
Forgot to type "NO"?
ThinkFree is offline  
Old 26-08-2008, 11:20 PM   #9 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
Default Re: How to use clrscr() function in gcc?

If using windows then try system("cls"); n if *nix then system("clear");

Actually, system() passes argument directly to shell...
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 26-08-2008, 11:21 PM   #10 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,657
Default Re: How to use clrscr() function in gcc?

Ah yes I did forget to include a "no". But system("clear") will not help in the same way as clrscr() of conio.h. The only way is ncurses if you want all features of dos.h/conio.h/etc windows stuff, and its a lot more powerful than that. You might just love it, why not give the link's tutorial a try? I liked it!
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 26-08-2008, 11:37 PM   #11 (permalink)
Alpha Geek
 
Krazy_About_Technology's Avatar
 
Join Date: Jun 2004
Location: Noida - India
Posts: 764
Default Re: How to use clrscr() function in gcc?

I guess you want some kind of unified solution so that your program works fine whether compiling in Windows or Linux. For that you'll have to do the one time dirty task of creating the "unified versions" of these functions in one of your custom header file. use #ifdef construct to comment out sections of your code that are irrelevent while running on a particular OS. Best way to create these unified version is to use ncurses for linux/unix and conio.h for windows.
__________________
Dell Inspiron 1525 - C2D 2 Ghz, 3GB, 250GB, X3100

Samsung Omnia Pro B7610 with Stock WM 6.1 ROM

Blog: http://www.sumitbhardwaj.co.in/blog
Krazy_About_Technology is offline  
Old 27-08-2008, 10:06 PM   #12 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,429
Default Re: How to use clrscr() function in gcc?

OK, will try ncurses
ThinkFree 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
A) Calling function rose tamang Programming 4 15-07-2008 01:20 PM
About C functions clrscr, delay. Cannot be found? aditya.shevade QnA (read only) 6 25-01-2007 09:45 PM
incorrect MS-DOS function?? rounit Software Q&A 9 12-01-2007 11:52 PM
PC function citizen Software Q&A 5 09-12-2006 11:55 PM
PHP mail function anilsmart Internet & WWW 11 29-10-2004 07:12 AM


All times are GMT +5.5. The time now is 03:16 AM.


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

Search Engine Optimization by vBSEO 3.3.2