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?

No, there is not standard C++ method of doing this, or at least not that im aware of. If your using linux i believe the ncurses or pdcurses headers may have something to heklp you out. If your on windows then you can use windows.h

  __in   HANDLE hConsoleOutput,
  __out  LPTSTR lpCharacter,
  __in   DWORD nLength,
  __in   COORD dwReadCoord,
  __out  LPDWORD lpNumberOfCharsRead
#include <iostream>
#include <windows.h>

int main(void){
   HANDLE hOut;
   COORD location = {3, 5};
   char letter;
   DWORD numberRead;

   hOut = GetStdHandle(STD_OUTPUT_HANDLE);

   ReadConsoleOutputCharacter(hOut, &letter, 1, location, &numberRead);

   std::cout << letter;

   return 0;

Hope that helps, note untested.


This question has already been answered. Start a new discussion instead.