Console in ANSI C or *nix - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Console in ANSI C or *nix

IDKIDK Posts: 1,784Member
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?

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2006-5-14 5:12:44[/red][/b][hr]
    : 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?
    [red]No[/red]
    : If not, is it possible to do it in C on unix?
    [red]No -- unix uses ansi c too :)[/red]
    : If not, is it possible at all?
    :
    [red]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.[/red]

    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


  • IDKIDK Posts: 1,784Member
    : [b][red]This message was edited by stober at 2006-5-14 5:12:44[/red][/b][hr]
    : : 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?
    : [red]No[/red]
    : : If not, is it possible to do it in C on unix?
    : [red]No -- unix uses ansi c too :)[/red]
    : : If not, is it possible at all?
    : :
    : [red]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.[/red]
    :
    : 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
  • IDKIDK Posts: 1,784Member

    : 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. ;-)
  • stoberstober Posts: 9,765Member ✭✭✭
    :
    : : 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/ client.c -lcurses

    also search your hard drive to insure the curses library is installed.
  • IDKIDK Posts: 1,784Member
    : :
    : : : 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/ 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
Sign In or Register to comment.