LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2007, 08:39 AM   #1
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Rep: Reputation: 30
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.
 
Old 09-13-2007, 10:50 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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.
 
Old 09-13-2007, 01:25 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
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).
 
Old 09-22-2007, 03:32 AM   #4
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Original Poster
Rep: Reputation: 30
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...
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Tools: GCC 3.4.6, Final GCC 3 Release LXer Syndicated Linux News 0 05-30-2006 02:21 AM
gcc equivalent for Visual C++ function: PeekNamedPipe () m3rc_2004 Programming 1 07-29-2005 05:58 AM
gcc wont install, 'failed dependencies: glibc-devel is needed by gcc-3.3.3-41' TdlSnare SUSE / openSUSE 3 11-29-2004 02:13 PM
a doubt with host gcc and arm-linux-gcc renjithgopal Linux - General 1 09-11-2003 04:02 PM
export CC=/usr/bin/gcc-3.2 - switch gcc version? ferreter Linux - Software 1 08-20-2003 12:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration