![]() |
|
gotoxy |
xerophreak
Member #745
November 2000
|
I'm having some trouble with the gotoxy function. whenever i tell it to go to xy and cout anything, it just couts what i tell it to where the rest of the output ended...it doesn't move anywhere...i'm using the function... |
Bruce Perry
Member #270
April 2000
|
Remember the top left corner of the screen is (1,1), not (0,0). I suspect it would ignore a call with one of the coordinates 0. If this doesn't work, try using printf() or cprintf() instead of cout - although I'd have thought it should work. Ben Davis -- |
xerophreak
Member #745
November 2000
|
I'm trying to give it the coordinates (15,15)but it just doens't do anything |
George Foot
Member #669
September 2000
|
The conio system works by writing directly to video memory. stdout (used by printf and cout) is a file descriptor. You can't mix the two. So, if you want to use gotoxy you have to use the other conio routines too, and no stdio routines or others that use stdout. That is, use cprintf or cputs. Maybe somebody has made a streamed version of it too, but I think it's more likely that someone has made a stream wrapper for gotoxy as well. |
xerophreak
Member #745
November 2000
|
the compiler we started on would work with the gotoxy function, but this one won't. i just need it to go frmo point to point and place a random character. any ideas on what i could get to do that? |
gswork
Member #771
November 2000
|
xero, Use conio.h as gfoot advised, for the random trickery you could fill an array with the characters you want and then point randomly to them. So in C you could 'char' an array of characters then declare a pointer to use in randomly (get a random Nr) pointing at an element in the array. You could set up the random selecting as a little function to return the character and call it inside a loop in main() or elsewhere however many times you want. I'm sure there are various other ways too, like stopping the same character from appearing twice etc. |
xerophreak
Member #745
November 2000
|
can someone give me an example of how to do it??? |
parasync
Member #683
October 2000
|
cprintf, same as printf only it works with textcolor(int), textbackground(int) and gotoxy(int, int) |
xerophreak
Member #745
November 2000
|
that's great and all, but can someone give me an example program that will print out an "X" at (15,15) ?? |
Thomas Harte
Member #33
April 2000
![]() |
#include <conio.h> [My site] [Tetrominoes] |
Thomas Harte
Member #33
April 2000
![]() |
Your previous C compiler was probably developed entirely with DOS in mind, so has a 'thrown together' stdout/stderr/stdin, hence it working where DJGPP does not. Be warned though : conio.h and gotoxy are very DOS things to do still, don't expect to be able to port even to Linux console if you're doing that kind of thing. I think 'curses' is the cleanest (for portability) thing to use for text mode manipulation . . . [My site] [Tetrominoes] |
xerophreak
Member #745
November 2000
|
it says ... |
parasync
Member #683
October 2000
|
Save all your data into an array of chars.. |
Bruce Perry
Member #270
April 2000
|
To solve 'implicit declaration' warnings, make sure you include the appropriate header files. I think you need conio.h - check the docs. -- |
|