How to make the last letter blink?

回眸只為那壹抹淺笑 提交于 2019-12-02 12:51:51

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;
    }
//---------------------------------------------------------------------------

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();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!