void clrscr(){ cout.flush(); static HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord = {0, 0}; DWORD dw; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwSize; GetConsoleScreenBufferInfo(hConsole,&csbi); dwSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, ' ', dwSize, coord, &dw); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwSize, coord, &dw); SetConsoleCursorPosition(hConsole, coord);}
console app-c++
If you use windows and want a fast function to clear the screen, try this code.
This maybe no use at all but...
Should work for windows or unix, for unix simply comment out the define statement, i think it's in the std namespace, haven't used it for a while but should get the job done in a simple manner.
Although Radagar's method looks far more intelligent (and complex for a simple app).
#define WIN32#ifdef WIN32 system("cls");#else system("clear");#endif
Should work for windows or unix, for unix simply comment out the define statement, i think it's in the std namespace, haven't used it for a while but should get the job done in a simple manner.
Although Radagar's method looks far more intelligent (and complex for a simple app).
#include <iostream>
using namespace std;
int main()
{
system("pause");
}
it works, before you tell me I am wrong, compile it.
using namespace std;
int main()
{
system("pause");
}
it works, before you tell me I am wrong, compile it.
Quote:Original post by game mercenary
#include <iostream>
using namespace std;
int main()
{
system("pause");
}
it works, before you tell me I am wrong, compile it.
system()
Also, iostream->istream->ostream->ios->xlocnum->cstdlib->stdlib.h
Quote:_CRTIMP int __cdecl system(const char *);
in VC++7.1, which is why it is 'working'. It is not, however, in iostream. It is in stdlib.h.
Regards,
jflanglois
Just use
#define CLRSCRN {for (int i=1;i<=200;++i) cout << "\n";}
Then use CLRSCRN in the code.
#define CLRSCRN {for (int i=1;i<=200;++i) cout << "\n";}
Then use CLRSCRN in the code.
Quote:Original post by game mercenary
#include <iostream>
using namespace std;
int main()
{
system("pause");
}
it works, before you tell me I am wrong, compile it.
[grin]
Quote:Original post by garyfletcher
Just use
#define CLRSCRN {for (int i=1;i<=200;++i) cout << "\n";}
Then use CLRSCRN in the code.
This works, but sometimes it causes flicker.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement