Mac Xcode - conio.h library

ojb13004

macrumors newbie
Original poster
Nov 26, 2013
4
0
I need to use the gotoxy function for a programming exercise I'm doing at university. This is a function found in the conio.h library. As this is not a standard library I need to be able to download and import the library ready to use. Can anyone do a walkthrough for me? I'd be very grateful, but please keep it simple, I'm not massively knowledgeable on computer jargon! Thanks!
 

chown33

Moderator
Staff member
Aug 9, 2009
8,726
5,042
vertical
Well I have managed downloaded a conio.h library to my mac. I just don't know how to implement it.
Where did you get this conio.h from? Please post the actual URL, or the URL of a page with a download link.


A conio.h file isn't a library, it's a header file. If there isn't an implementation in some other file or files that comes with the header file, you don't have the whole thing.

At most, a header file declares functions and variables, which will then need to be linked in from a conio library. A header is not an implementation. The implementation would need either some .c files (a source-code implementation) or a .dylib file (a shared library) or a static library (a .a file).

Read more on conio.h in this Wikipedia article:
http://en.wikipedia.org/wiki/Conio.h


Think of a header file as a promise to the compiler that there will be functions and variables with the declared names when the time comes to link the program. If the header is a promise, then the linkable library is the fulfillment of that promise. If the fulfillment is missing (the library), then the promise (header) means nothing. All you get is a bunch of broken promises (linker errors) saying that such-and-such function or variable can't be found.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
As have been mentioned, it's a non standard, old header file that's not really used anymore. Most likely your lab or class does not depend on this header file for anything important, i.e you will do just fine without it.

A quick google showed an ansi escape equivalent that may work for you as a replacement, if you must use it.

Code:
void gotoxy(int x, int y) {
    printf("\x1b[%d;%df", y, x);
}
The closest thing you get on Unix or OS X is probably curses or termios, but non of them are drop in replacements by any means, they are both defined in the posix standard however.
 

robvas

macrumors 68040
Mar 29, 2009
3,045
511
USA
Here's what you need to do - install VirtualBox (free) and install Windows XP (you could also use DOSBox). The next thing you do is download the old Turbo C compiler from Borland, they have made them free since they are so old:

http://edn.embarcadero.com/article/20841

Then you can use conio.h inside that old compiler inside of DOS/Windows. There's also a version of conio.h you can use on Sourceforge that works with the free MingW compiler for Windows.
 

ofbarea

macrumors newbie
Dec 20, 2013
2
0
Hi, there is conio implementation for Linux and chances are that it will work on OS X.

Take a look:
http://sourceforge.net/projects/linux-conioh/

Just keep the following coment in mind:
"Guys, it works with a bit of tinkering around. The developer decided to celebrate 6 New Year's without us. diff a/conio.h b/conio.h 297a298 > return 0; ------------------------ forcing ncurses by putting '#include <ncurses.h>' in all files resolves all compile errors. ------------------------ compiler: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3"

Hope this helps.
 

sharon9662

macrumors newbie
Oct 15, 2016
1
0
As have been mentioned, it's a non standard, old header file that's not really used anymore. Most likely your lab or class does not depend on this header file for anything important, i.e you will do just fine without it.

A quick google showed an ansi escape equivalent that may work for you as a replacement, if you must use it.

Code:
void gotoxy(int x, int y) {
    printf("\x1b[%d;%df", y, x);
}
The closest thing you get on Unix or OS X is probably curses or termios, but non of them are drop in replacements by any means, they are both defined in the posix standard however.

In doing so the the coordinates are printed aswell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.