LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   equivalent of conio.h in gcc? (and some more gcc-newbie questions) (https://www.linuxquestions.org/questions/programming-9/equivalent-of-conio-h-in-gcc-and-some-more-gcc-newbie-questions-584403/)

Valkyrie_of_valhalla 09-13-2007 08:39 AM

equivalent of conio.h in gcc? (and some more gcc-newbie questions)
 
I'm having a few problems in learning C under Linux.

Background: It's my first encounter with C (I do know other programming languages), and I'm learning from an old book, that explains mostly the C from Borland C (and it's from 1994).

So far so good, I read the book and compiled a lot of programs (mostly math and common algorythms - backtracking, graphs, etc.) with GCC on Linux.

Now I'm reading the part on screen manipulation. Surprise: there is no conio.h in gcc!

I googled and learned about ncurses.h. I learned a bit about it and seems to be able to do quite a lot of things, but... there is no equivalent of gotoxy()!

Questions:

1. Is there an equivalent of gotoxy in gcc? If so, where, and where can I find it (in which header)?

2. Are there any other incompatibilities? Any other commonly used Borland C headers that are missing in GCC?

3. Can you recommend a good book on C for GCC?

Thanks for reading. Any answers and ideas are welcomed. If you would like to share some tips or suggestions regarding programming under Linux (what else I should focus on, etc), they are welcomed as well.

kev82 09-13-2007 10:50 AM

I believe the curses function you are looking for is move().

http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

There are plenty of books out there that teach standard C, although I personally don't know any of them. However, if you are already competent enough to write graph datastructures and similar things, then I doubt there is much you could learn from such a book.

Things such as console control/graphics/... are not provided by the C language, instead they are done with libraries, such as curses. If you wish to do stuff like this you must find an appropriate library to do the task for you. Some examples of libraries:

expat (I use this a lot to parse XML)
pslib (I use this to create postscript files)
boost (this is actually a C++ library, but contains a lot of stuff that should already be in C++)
libmysql (for connecting to mysql servers)
...
...

The list is almost infinite. For a small taster of the libraries available to you have a look in /usr/lib. If you see anything that sparks your interest, google it. All libraries will publish documentation of one form or another, most is free when you download the library.

osor 09-13-2007 01:25 PM

Just a clarification for the original poster: curses.h is not part of gcc. In fact very little of the Standard C library is even part of gcc. GCC only includes the bare minimum for complying with the C standard for a conforming freestanding implementation (i.e., no library features save those specified in float.h, iso646.h, limits.h, stdarg.h, stdbool.h, stddef.h, and stdint.h). Anything else is provided by a separate library to which you may link your program.

In the case of the C library, there is glibc which provides the familiar headers such as stdio.h. Linking to glibc happens automagically when you compile with gcc. In the case of the curses or new curses libraries, there is GNU Ncurses, which provides headers such as curses.h. To link to such a library, you have to specify to gcc or ld with “-lcurses” (this makes the resultant executable incorporate code from the library object files).

Valkyrie_of_valhalla 09-22-2007 03:32 AM

Thanks for your replies.
Seems move() was what I was looking for. I missed it when I read about ncurses for the first time (and I didn't have time to re-look until now).
I've got to get used to the Linux way of doing things related to programming...


All times are GMT -5. The time now is 11:31 AM.