I\'d recently created this program that displays the last letter of a string. Using this code:
#include
#include
#include
You can use textcolor(); 128 code is blink code in turboc++
#include<conio.h>
#include<stdio.h>
int main(){
clrscr();
textcolor(128+6); // or textcolor(134) [128:blinking and 6:brown color]
cprintf("My name is Prashant");
getch(); }
for more help right click on turboC++ window and type textcolor();
This is what you are looking for:
//---------------------------------------------------------------------------
#include<conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
for (int i=32;i<256;i++)
{
textcolor(i);
cprintf("%c",i);
}
getch();
return 0;
}
//---------------------------------------------------------------------------
the colors are set with:
textattr(full_attribute);
textcolor(font_color);
textbackground(background_color);
The blinking does not work on my console (Win7) so if you got the same problem you need to animate your self try this:
//---------------------------------------------------------------------------
#include<conio.h>
#include<dos.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char *txt="text\0";
_setcursortype(0); // hide cursor
for (;;)
{
gotoxy(1,1); // print position
textattr(7); // white on black
cprintf("%s",txt);
sleep(1); // wait 1 sec
gotoxy(1,1); // print position
textattr(0); // black on black
cprintf("%s",txt);
sleep(1);
if (kbhit()) { getch(); break; } // stop on any key hit
}
// restore console properties
textattr(7);
_setcursortype(1);
return 0;
}
//---------------------------------------------------------------------------