My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://ashokbasnet.com.np
and update your bookmarks.

Saturday, May 22, 2010

gotoxy in Code::Blocks

Solution to gotoxy in codeblocks.

1. #include <windows.h>
2. Define a global variable  COORD coord = {0, 0}; // sets coordinates to 0,0
3. Make a function gotoxy()
void gotoxy (int x, int y)

        coord.X = x; coord.Y = y; // X and Y coordinates
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

You can call this gotoxy()  function to put cursor at any postion.

to change cursor type i.e. blinking,

_setcursortype(_NORMALCURSOR);  //for normal blinking cursor                               _setcursortype(_NOCURSOR);  //for NO cursor                                                                                      put these functions accordingly where u need it