the gotoxy(int x, int y) function

R

Richard Bos

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

Imprimis, "free download" is not the same thing as "system headers".
Secundis, not all C compilers running under M$ OSes use libraries
compatible with the M$VC libs.

Richard
 
O

osmium

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.

I think you may misunderstand how things fit together. In general, two
things are necessary to introduce some new functionality to a C program, a
header file (conio.h *is* a header file) and the code to go with it in some
sort of "lib" file. The header file just contains declarations (function
prototypes) no definitions (actual code) for the corresponding function.

Simply including the .h file, which you suggest, is just lying to the
compiler. You promise the compiler there will be, at link time, object
code from some other place, from a separate compilation or from some
precompiled library. But such doesn't actually exist. IOW, conio.h (and
the matching code) exist on the platform(s) *you* have checked, sending the
OP a copy of your conio.h would just result in confusing error messages for
him.
 
K

Keith Thompson

Mark McIntyre said:
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.

Presumably it acts within the window in which the program is currently
executing. Don't most windowing systems have a concept of the
"current window"?

Whatever it means, it's certainly possible to assign a sensible
meaning to it. (Of course, what that meaning is is a topic for
another newsgroup.)
 
R

Richard Tobin

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.
[/QUOTE]
Presumably it acts within the window in which the program is currently
executing. Don't most windowing systems have a concept of the
"current window"?

Not exactly, in systems I have used. The nearest that X has is "the
window with the input focus", which is not what you want. I would
expect this kind of interface to be most useful in cases where the
window system is only being used by the C program in the sense of
having FILEs connected to terminal emulator windows, in which case it
might operate on the window that stdout is connected to.

-- Richard
 
K

Keith Thompson

Not exactly, in systems I have used. The nearest that X has is "the
window with the input focus", which is not what you want. I would
expect this kind of interface to be most useful in cases where the
window system is only being used by the C program in the sense of
having FILEs connected to terminal emulator windows, in which case it
might operate on the window that stdout is connected to.

This is straying further off-topic, but the routines I've seen with
the name "gotoxy" usually operate on text windows.

And since the original poster presented a declaration for a function
that takes only X and Y arguments, it's reasonable to assume that it
must have some way to determine which "window" (or whatever) to
operate on.
 
R

Richard Heathfield

Keith Thompson said:

This is straying further off-topic, but the routines I've seen with
the name "gotoxy" usually operate on text windows.

The first gotoxy I came across was in BASIC, on a microcomputer that didn't
bother to distinguish between "text window" and "graphics window" - all
you got was "glass window".
And since the original poster presented a declaration for a function
that takes only X and Y arguments, it's reasonable to assume that it
must have some way to determine which "window" (or whatever) to
operate on.

You're assuming the OP has a windowing system, which is by no means a
given.
 
T

Thomas Dickey

Imprimis, "free download" is not the same thing as "system headers".

....a comment which is a waste of bandwidth.
Secundis, not all C compilers running under M$ OSes use libraries
compatible with the M$VC libs.

...ditto.

(perhaps you'll find time to make an intelligent response - bye)
 
Joined
Jan 20, 2009
Messages
1
Reaction score
0
That all depends on your compiler. The original Borland C++ included gotxy(int,int), (don't know about TURBO C++). It also had some great graphic.h commands with no fuss. I'm using Dev-C++ now and it's a lot like the good ol K&R raw C. #include windows.h has a bunch of goodies, too. I'm using windows Vista and I ended up using the following, note the 'while' command at the end using 'q' to exit - this is where the rest of your program might go...I tried to pass the x and y entries to the function from main() in one step but kept getting an error; "Function must be followed by whitespace character", which I had. Whatever... Oh, there's some unnecessary stuff there for the rest of my program.

//* GOTO_XY Function

#include <stdio.h>
#include <iostream>
#include <conio.h>
#include <ctype.h>
using namespace std;


char a[5];
int i,x,y;
char c;

int CURSOR_X (int x)
{
for(i=0; i<x; ++i)
printf(" ");
return (0);
}
int CURSOR_Y (int y)
{
for(i=0; i<y; ++i)
printf("\n");
return (0);
}

main()
{
printf("Enter X Value");
cin>>x;
printf("Enter Y Value");
cin>>y;
// printf("X=%d, Y=%d", x, y);
system ("cls");

for(i=0; i<10; ++i)
{
CURSOR_Y (y);
CURSOR_X (x);
printf("XY = %d X %d", x, y);
}

while(c != 'q')
cin >> c;

return 0;
} //end of main
 
Last edited:

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

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
IRMNikole

Latest Threads

Top