Everyone likes to add some color and features to their program. This is the easiest way to achieve it, but it uses OS functions and clears the whole screen. There are much more efficient ways to achieve this, but this is a very easy way nevertheless.
Update: CppBuilder2006 found some errors in the code in Borland compilers, and the code was updated to work with VC++ and Borland.
Code
Just compile and run. I am sorry about the indenting problem. This codebox is having issues at the moment.
#include <iostream>
#include <windows.h>
using namespace std;
enum Colors { blue = 1, green, cyan, red, purple, yellow, grey, dgrey, hblue, hgreen, hred, hpurple, hyellow, hwhite };
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int main(int argc, char* argv[])
{
// print, clear, then print again 10 times
for (int i = 0; i < 10; i++)
{
system("cls");
SetConsoleTextAttribute(handle, hwhite);
cout << "HI!\n";
cout << "This is blinking text =)";
Sleep(500);
system("cls");
cout << "HI!\n";
system("cls");
}
return 0;
}
1 comments:
Thank you
I really needed it!
Good Luck
Post a Comment