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

ReadConsoleOutputCharacter(
  __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;

   std::cin.get();
   return 0;
}

Hope that helps, note untested.

Chris

Thanks for the help. I will try to work it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.