Hello everyone this is my first contribution in this website ..
I am looking for a function or manner to know everytime the function being called the position of the cursor like this way
int main()
{
cout << "The position now is : " << get_position() << endl;
cout << "and now is : " << get_position() << endl;
}
@ Duoas: How is it that with over 6000 posts you are still able to link back to entries you made almost 4 YEARS AGO?!?!?! Never-mind how you even remembered you made it, I'll just assume you have an eidetic memory in that regard.
LOL. That, and Google helps me find stuff when I can't be bothered. :O)
(Also, I do tend to remember the kinds of posts I've made several hundred times over. Which is easy, as I tend to post what I know about anyway... Alas, as Holmes said, "you know a conjurer gets no credit when once he has explained his trick".)
@ Duoas: Maybe the OP has ESL and is having trouble reading your code\post?
@ OP: The link that Duoas provided gives you three functions, (NOTE: This will only work in windows). The ones you are interested in are "wherex()" at Lines 14-24 and "wherey() at Lines 26-36. "wherex()" will give the the X coordinates of the cursor, or how many character spaces it is in from the left side of the screen. The "wherey()" function gives you the Y coordinates, or how many lines from the top of the screen the cursor is.
Now for your purposes you can simplify his code and just call "GetScreenBufferInfo()" once. The CONSOLE_SCREEN_BUFFER_INFO struct pointed to in the second argument has a memeber called "dwCursorPosition" that will hold both the X and Y coordinates once "GetScreenBufferInfo()" returns.
Oh wow, there seems to be a glaring mistake in Duoas's code. You want to return the variable "csbi.dwCursorPosition.X" and "csbi.dwCursorPosition.Y" not "result", result doesn't hold anything. I assume he meant to assign the COORD variables to "result" at some point but it's not done here in his example.