- #1
chrisalviola
- 80
- 0
Is there a way I can write characters or numbers anywhere on the screen in C++ like the ones used in pascal like gotoxy where I simply write screen coordinates as x & y.
mgb_phys said:Under unix there is a library called curses (or ncurses in newer versions) to do printing effects on a character terminal.
Under a GUI it would depend on what platform but most have the ability to write text at a particular coordinate in a window, or you could use something like OpenGL.
Gotoxy is a C++ function that allows you to set the cursor to a specific position on the screen. This is useful when creating text-based games or programs that require a specific layout.
To use Gotoxy, you need to include the header file #include <windows.h>
in your code. Then, you can call the function gotoxy(x,y)
to set the cursor to the desired position, where x
and y
are the coordinates of the position you want to move the cursor to.
Yes, Gotoxy is a standard C++ function and can be used in any C++ compiler. However, it may not work on all operating systems as it relies on the windows.h
header file.
If you use Gotoxy to set the cursor outside the boundaries of the screen, it will not display an error but it may cause unexpected behavior in your program. It is important to ensure that the coordinates you pass to Gotoxy are within the screen boundaries.
Yes, there are other ways to achieve similar results as Gotoxy in C++. For example, you can use the SetConsoleCursorPosition
function from the windows.h
header file. Additionally, some graphics libraries like ncurses
also provide similar functions for positioning the cursor on the screen.