C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Console in ANSI C or *nix Posted by IDK on 14 May 2006 at 3:49 AM
How do I
clear the console,
get position where I am on the console,
and set position?

Is it possible to do it in ansi C?
If not, is it possible to do it in C on unix?
If not, is it possible at all?
Report
Re: Console in ANSI C or *nix Posted by stober on 14 May 2006 at 5:11 AM
This message was edited by stober at 2006-5-14 5:12:44

: How do I
: clear the console,
: get position where I am on the console,
: and set position?
:
: Is it possible to do it in ansi C?
No
: If not, is it possible to do it in C on unix?
No -- unix uses ansi c too :)
: If not, is it possible at all?
:
Yes. use curses library functions. unlike ms-windows, *nix supports hundreds of terminal types and each one has its own way of moving the cursor around the screen. That is why there are no standard ascii c functions to control the cursor. I suppose you could do your own thing with the terminfo.h and associated library, but that would entail pretty low-level programming. There might be another console lib like curses but I don't know of one.

http://72.14.203.104/search?q=cache:ZfI2zzPOK4YJ:heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf+man+curses&hl=en&gl=us&ct=clnk&cd=5


Report
Re: Console in ANSI C or *nix Posted by IDK on 14 May 2006 at 6:00 AM
: This message was edited by stober at 2006-5-14 5:12:44

: : How do I
: : clear the console,
: : get position where I am on the console,
: : and set position?
: :
: : Is it possible to do it in ansi C?
: No
: : If not, is it possible to do it in C on unix?
: No -- unix uses ansi c too :)
: : If not, is it possible at all?
: :
: Yes. use curses library functions. unlike ms-windows, *nix supports hundreds of terminal types and each one has its own way of moving the cursor around the screen. That is why there are no standard ascii c functions to control the cursor. I suppose you could do your own thing with the terminfo.h and associated library, but that would entail pretty low-level programming. There might be another console lib like curses but I don't know of one.
:
: http://72.14.203.104/search?q=cache:ZfI2zzPOK4YJ:heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf+man+curses&hl=en&gl=us&ct=clnk&cd=5
:
:
:
Thanks
Report
Re: Console in ANSI C or *nix Posted by IDK on 14 May 2006 at 1:24 PM

: Thanks
:
One problem though, I compile with:
gcc -g client.c -lcurses
but it says:
client.c:16:20: curses.h: No such file or directory

I tried to compile with -lncurses too but it didn't work either...

Why is it called curses?
Becouse the include is cursed.
Report
Re: Console in ANSI C or *nix Posted by stober on 15 May 2006 at 1:10 PM
:
: : Thanks
: :
: One problem though, I compile with:
: gcc -g client.c -lcurses
: but it says:
: client.c:16:20: curses.h: No such file or directory
:
: I tried to compile with -lncurses too but it didn't work either...
:
: Why is it called curses?
: Becouse the include is cursed.
:


you may have to specify the full path to the curses .h files
gcc -g -I/<path to header files here> client.c -lcurses

also search your hard drive to insure the curses library is installed.
Report
Re: Console in ANSI C or *nix Posted by IDK on 16 May 2006 at 3:30 AM
: :
: : : Thanks
: : :
: : One problem though, I compile with:
: : gcc -g client.c -lcurses
: : but it says:
: : client.c:16:20: curses.h: No such file or directory
: :
: : I tried to compile with -lncurses too but it didn't work either...
: :
: : Why is it called curses?
: : Becouse the include is cursed.
: :
:
:
: you may have to specify the full path to the curses .h files
: gcc -g -I/<path to header files here> client.c -lcurses
:
: also search your hard drive to insure the curses library is installed.
:
I searched for it and it couldn't be found, so I downloaded it.
Now the hard part is to understand the instructions to install...

Thanks



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.