the gotoxy(int x, int y) function

A

Albert

Hi
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header

Albert
 
I

Ian Collins

Albert said:
Hi
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header
Your compiler may not, but you operating system headers might. Try an
OS specific group.
 
K

Keith Thompson

Albert said:
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header

There's no such function in standard C. It's undoubtedly part of some
system-specific library. In fact, it's very likely that there are
several such functions in different libraries that do different
things.

You'll need to find and install whatever library provides it.

<OT>The <conio.h> header declares such a function; presumably it
exists only on Windows-like or DOS-like systems.</OT>
 
B

Ben Pfaff

Albert said:
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header

gotoxy is not a standard C library function, so many C
implementations do not come with it. Also, see the C FAQ:

10.11: I seem to be missing the system header file <sgtty.h>.
Can someone send me a copy?

A: Standard headers exist in part so that definitions appropriate
to your compiler, operating system, and processor can be
supplied. You cannot just pick up a copy of someone else's
header file and expect it to work, unless that person is using
exactly the same environment. Ask your compiler vendor why the
file was not provided (or to send a replacement copy).
 
M

Malcolm McLean

Albert said:
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header
No.
If you have a screen display then almost certainly there will be an
equivalent. So just write gotoxy() to call it.
This almost never affects printf() and the other standard functions. They
treat output as a stream. However there is usually a non-standard printat(),
ConPrintf() or similar that treats the screen as a raster of characters, and
has its own cursor and colour state.
 
J

jacob navia

Albert said:
Hi
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header

Albert

Under the windows OS, lcc-win32 provides a compatibility library with
that function. It uses the console API of windows.

Under linux there are several libraries that provide that function,
specially the "curses" library, that makes for a portable interface
to the console/terminal.
 
K

Keith Thompson

jacob navia said:
Under the windows OS, lcc-win32 provides a compatibility library with
that function. It uses the console API of windows.

I would guess that any Windows compiler would provide something
similar. Is lcc-win32 unique enough in this regard to be worth
mentioning here?
Under linux there are several libraries that provide that function,
specially the "curses" library, that makes for a portable interface
to the console/terminal.

I don't believe curses provides anything called "gotoxy". Also,
curses is a higher level interface than the Windows console API, so
moving the cursor to an arbitrary location (which I presume is what
the OP is looking for) doesn't necesssarily mean what you might think
it does.

The OP should ask in a system-specific newsgroup, after reading
question 19.4 in the comp.lang.c FAQ, <http://www.c-faq.com/>.
 
K

Keith Thompson


I took a look at that. The code assumes ANSI escape sequences. That
may be a fairly safe assumption these days, but since Unix provides
termcap and/or terminfo, which allow for terminal independence,
there's not much point in doing that.

And the function wastefully builds the string to be printed once piece
at a time using sprintf and strcat. The whole thing could be replaced
with this:

void gotoxy(int x, int y)
{
printf("\033[%dd\033[%dG", y, x);
}

The sample gotoxy() implemntation starts with '#include <iostream.h>',
a C++-specific header, though I don't see that it uses anything from
it. (I'd mention that it really should be '#include <iostream>' if it
were topical.)
 
S

sped.vind

Hi
Are there any definitions of the gotoxy function on the internet. My
compiler doesn't define it in any header

Albert

hi everybody,
im a newbie here and to the C language, i understood your problem, as
far as i know its in the conio.h header file both in C and C++, i have
checked it, so if you want to use it, you can simply include the file.
Well if i'm wrong somewhere please let me know so that i can correct
myself.
Thank you
 
J

jacob navia

Keith said:
I would guess that any Windows compiler would provide something
similar. Is lcc-win32 unique enough in this regard to be worth
mentioning here?

I do not know. The library is a clone of the old turbo C of Borland
with the same interface. As far as I know, MSVC does not provide it,
gcc under windows doesn't either, but I do not know ALL windows
compilers either.
 
M

Malcolm McLean

hi everybody,
im a newbie here and to the C language, i understood your problem, as
far as i know its in the conio.h header file both in C and C++, i have
checked it, so if you want to use it, you can simply include the file.
Well if i'm wrong somewhere please let me know so that i can correct
myself.
The snag is that many platforms don't have a conio.h. It's non-standard.

That doesn't mean that it is a bad thing to use the conio functions, however
your program will not them work when transferred to another machine.
stdio.h, on the other hand, is ANSI.
 
M

Malcolm McLean

jacob navia said:
I do not know. The library is a clone of the old turbo C of Borland
with the same interface. As far as I know, MSVC does not provide it,
gcc under windows doesn't either, but I do not know ALL windows
compilers either.
There's always some way to move the cursor about the screen, even if you
curse the cluntzy interface.
 
K

Keith Thompson

Malcolm McLean said:
There's always some way to move the cursor about the screen, even if
you curse the cluntzy interface.

Not all implementations have a cursor. Not all of those that do are
able to move it to arbirary locations.
 
R

Richard Bos

Ian Collins said:
Your compiler may not, but you operating system headers might.

Not very likely. It's a conio function, which is almost always used with

M$ operating systems, which don't come with OS headers or libs.

What Albert needs to do is to figure out what he _really_ wants to do,
not which function he believes he is expected to use; and _then_
consider which newsgroup that would be topical in. Here it isn't.

Richard
 
C

CBFalconer

Richard said:
Not very likely. It's a conio function, which is almost always used
with M$ operating systems, which don't come with OS headers or libs.

What Albert needs to do is to figure out what he _really_ wants to
do, not which function he believes he is expected to use; and _then_
consider which newsgroup that would be topical in. Here it isn't.

gotoxy and conio are not present on standard C compilers (the
subject of this newsgroup) and are thus off-topic here. Find a
newsgroup that deals with your peculiar system.
 
M

Mark McIntyre

I would guess that any Windows compiler would provide something
similar. Is lcc-win32 unique enough in this regard to be worth
mentioning here?

IMHO It doesn't make much sense in a multi-Window environment. goto
x,y on which window ? On the entire desktop? On my nth virtual
desktop? x,y measured in pixels, pels, inches, glyphs? measured top
down (like Excel) or bottom up?

It made perfect sense in the good old DOS days when you had exactly
one window.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
T

Thomas Dickey

Richard Bos said:
Not very likely. It's a conio function, which is almost always used with
M$ operating systems, which don't come with OS headers or libs.

yawn - another technologically obsolete remark
(headers and libraries have been a free download for many years).
 
R

Richard

Keith Thompson said:
Not all implementations have a cursor. Not all of those that do are
able to move it to arbirary locations.

And in those instances, we wouldn't be discussing how to use gotoxy() ...
 
R

Richard

CBFalconer said:
gotoxy and conio are not present on standard C compilers (the
subject of this newsgroup) and are thus off-topic here. Find a
newsgroup that deals with your peculiar system.

The subject of this newsgroup is the C Programming language. Nothing to
do with "standard compilers".

comp.lang.c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top