Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

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!
 
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.
 
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.
 
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.
 
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.
 
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
Screen%20Shot%202016-10-15%20at%201.59.15%20PM.png
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.