To do that you have to get down to the nitty-gritty with the operating system. The curses library (*nix) or ncurses (MS-Windows) will make that easier for you. For MS-Windows there are several other options depending on the compiler you are using.
if your developing for windows and don't wanna go download some extra libraries and things then you can use the Win32 API. It give's you all the stuff you need to do this, just if your a beginner it might be a little complex.