c++ - How to blink particular text continuously all time during input and output? -
here code blinks 'welcome' after user enter name.
'welcome' not blink when user writing name. user hits enter caret goes while loop. caret position set coordinates of 'welcome' & cout prints 'welcome' 5 colors again & again seems 'welcome' blinking.
but want 'welcome' blinks continuously program starts.
so more question ask - can have 2 caret/cursor @ same time ?
#include <iostream> #include <conio.h> #include <windows.h> using namespace std; int main(int argc, char** argv) { int x,y,i;char name[10]; textcolor(10); x=wherex();y=wherey(); //corrdinates of caret stored in x & y. cout<<"\t\t\t\twelcome\n"; textcolor(15); cout<<"\nenter name\n"; gets(name); while(1) { for(i=10;i<15;i++) { textcolor(i); gotoxy(x,y); //transferring caret coordinates stored in x & y. cout<<"\t\t\t\twelcome"; sleep(300); } } return 0; }
i wrote small code question , it's not 100% correct answer. posting answer giving little bit idea newbie.
#include <iostream> #include <conio.h> #include <windows.h> using namespace std; int x,y,b,l,n=0; char c; void blink() { { int m; for(m=10;m<15;m++) { textcolor(m); gotoxy(x,y); cout<<"\t\t\t\twelcome"; sleep(60); } } } int main(int argc, char** argv) { char i;int key_stroke; textcolor(10); x=wherex();y=wherey(); cout<<"\t\t\t\twelcome\n"; textcolor(15); cout<<"\nenter name\n"; l=wherex();b=wherey(); z: { while (1) { if(!(_kbhit())) { blink(); goto z; } else { i=_getch(); if(i==13) { gotoxy(l+n,b+1); return 0; } textcolor(10); gotoxy(l+n,b); cout<<i;n=n+1; } } } return 0; }
Comments
Post a Comment