I know these functions in C, but in C++ they doesn't work.
What is replacement for these functions in C++ ?

wherex, wherey, gotoxy are all Borland extensions. (Do Borland compilers still support them?) You can learn how to do it using the OS functions directly yourself.

Oh yes its Borland extensions :)
I dont understand this : "You can learn how to do it using the OS functions directly yourself. "

Well, Borland doesn't do it through magic, so there is a way to do it without their functions. For instance, if you are on Windows you would use SetConsoleCursorPosition instead of gotoxy, GetConsoleScreenBufferInfo instead of wherex and wherey, and SetConsoleTextAttribute instead of whatever you would use to set the color. Let me know if you need more info.

Can someone tell me extansion in Visual C for wherex() and wherey() is?
I know to do that at Borlands but not in Visual.. :\
Tnx :twisted:

You can find the functions you need here -> Windows Console Functions

Here, I wrapped them for you:

#include <windows.h>
#include <iostream>

void gotoxy(int x, int y)
    COORD pos = { x, y };

    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);

int wherex()

    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);

    return csbi.dwCursorPosition.X;

int wherey()

    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);

    return csbi.dwCursorPosition.Y;

int main()
    gotoxy(30, 10);

    std::cout << "Hello, World!";

    int x = wherex();
    int y = wherey();

    gotoxy(0, 0);

    std::cout << "end pos of \"Hello, World!\" = ";
    std::cout << "(" << x << ", " << y << ")" << std::endl;


WoW, it isn`t like we learn in school.. :O
But, tnx for reply...

That's because your school teaches 20-year-old techniques on 20-year-old software. They don't bother teaching today's C/C++.

They don't bother teaching today's C/C++.

That's not even today's C++. If they tried to teach today's C++, the teachers stuck in 1990 would have a stroke.

This article has been dead for over six months. Start a new discussion instead.