DIGIT-ARC read-only archive · snapshot: July 23, 2026

c++ help needed

7 posts · originally from https://geek.digit.in/community/threads/c-help-needed.99930/

M
masterovpuppetz Original post #1
Oct 16, 2008 at 12:29 PM
I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
dheeraj_kumar
Oct 17, 2008 at 2:20 AM
The screen is an output device, its for echoing the data in the memory. You cant read from the output device. What exactly are you trying to do? We can suggest alternatives for that.
L
Oct 17, 2008 at 2:16 PM
I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
well you can do it if you are in Win98 by directly accessing the video ram buffer located at 0xB8000, in physical memory. The buffer is of the datatype 'short', Each 16-bit element in the text memory buffer is broken into an 'upper' 8-bits and a 'lower' 8-bits. The lower 8 bits of each element tells the display controller what character to draw on the screen. We just have to extract this lower byte

use the following code

Code:
index = (y_value_cur * width_of_screen) + x_value_cur;
unsigned short *where = (unsigned short *)0xB8000 + index;
this code will give you direct access to the location where your cursor is

now to move to next or previous position just increment or decrement the where pointer .
M
Oct 17, 2008 at 6:50 PM
Thnx for the replies .I figured out a way to get the job done.
M
Oct 19, 2008 at 10:00 PM
as u guys said tht it was not possible to get input from buffer screen using standard c++,i modified my code (infact had to reprogram about two thirds of it).

So now instead of getting the x,y coordinates during runtime, I have made a array of x,y coordinates( which holds the desired character) and check wether the cursor coordinates is next to ne of these predefined coordinates.

Not the best way to do the job i guess, but at least the program is working !!
dheeraj_kumar
Oct 19, 2008 at 10:46 PM
^^ Yeah, thats probably the best way.