equivalent of conio.h in gcc? (and some more gcc-newbie questions)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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).
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.