gotoxy() function in Code::blocks(gcc compiler) using C

In Turbo C/C++ and Borland C++ compiler, gotoxy() is build in function. You need not have to write its function definition. All you have to do is call the function with arguments as x and y coordinate. But in modern C compilers like gcc and IDE Code::Blocks, gotoxy() is not build-in function, you have to define it before use them. The following code is the function definition for gotoxy(). Remember: This function only works on windows, because the function definition includes functions of header file “windows.h”. So to use gotoxy() you must include “windows.h”.

COORD coordinate = {0,0}; //initialization

void gotoxy(int x, int y){ //function definition

   coordinate.X = x; coordinate.Y =  y;



NOTE: coordinate (0,0) is left-top corner of your window.

SHARE gotoxy() function in Code::blocks(gcc compiler) using C

You may also like...

8 Responses

  1. Adil Nasir says:

    but it is giving an error that "setconsolecursorposition" is undeclared. first use this function.

  2. Hi Adil, The error comes from here:


    We must change Postion by Position.

    SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);


  3. Anonymous says:

    same here , undefined reference to `SetConsoleCursorPostion'

  4. It gives an error that "expected ';' before 'COORD' "… Please help…

  5. I have problem in this… This shows a error as… "expected ';' before 'COORD' "… Please Help

  6. It gives an error that "expected ';' before 'COORD' "… Please help…

  7. Anonymous says:

    how to do make a linklist about the dequeue, dequeue,enqueue
    please help me…

  8. Be Alone says:

    Dont write the first linw bro….

Leave a Reply

Your email address will not be published. Required fields are marked *