Is there any method in C programming by which i can clear a part of the screen, i.e the last few lines displayed?
Is there any method in C programming by which i can clear a part of the screen, i.e the last few lines displayed?
Which OS?
Not everything that can be counted counts, and not everything that counts can be counted
- Albert Einstein.
No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
- Herbert Mayer
Windows XP is the operating system
WriteConsoleOutput perhaps?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Though im not sure it is what you want, and most people will agree that it is not the best way. On windows you can use a simple system call
system("cls");
and on linux
system("clear");
I use them for simple little problems, and yes most people will agree here that it is not the best way either
or you could use soemthing like what this guy Matt had:
Code:#ifdef WIN32 # include <windows.h> void clearscreen(void) { DWORD n; /* Number of characters written */ DWORD size; /* number of visible characters */ COORD coord = {0}; /* Top left screen position */ CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(h, &csbi ); size = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(h, TEXT(' '), size, coord, &n); GetConsoleScreenBufferInfo(h, &csbi); FillConsoleOutputAttribute(h, csbi.wAttributes, size, coord, &n); SetConsoleCursorPosition (h, coord); } #else # include <curses.h> void clearscreen(void) { clear(); /* You need curses installed though */ } #endif
You can use the windows api "setcursorposition", to set the cursor at the head (left side) of each row you want to start full or partial deletion.
Then print to the screen, using the foreground and the background colors you want. That will make a text screen be "cleared".
This was shown a few months back. If you search for "gotoxy", and my name, you should find it fairly easily.
If not, post back, I do have some code that shows it. I should be able to dig it up. This is for a console "text" window, and does not use the ncurses library.