Hello everyone ok straight to the point
i have to do this
a text or a word that is blinking and have color
and while it is blinking it is automatically changing its color
i know how to do a text with color and blinking but i don't know
how automatically changing while it is blinking or randomize the color...
Please help me i begging someone....

Check out the functions rand() and srand() for randomization. You can use those functions to generate yourself some RGB values and then change the values of the text color to the generated values.
Show us some code of how you're planning to make the text blink, or change the color of the text maybe then more answers will follow.

The only way I can think of to change the color of the text on every blink is to write a clock interrupt function and change the color in that function. Clock ticks about once every millisecond, so your interrupt function will want to make the change only once every 1,000 ticks. Turbo C++ may have a compiler-specific function to help you with that, I don't know.

Looks like this and this, with a new username.

Show us what you managed to figure out so far, so we only have to fill in the gaps (as opposed to giving you everything, which simply won't happen).

commented: +1 +15
#include <conio.h>
#include <stdio.h>
#include <graphics.h>

	int main()
	   {
	       textcolor(YELLOW + BLINK);
	       cputs("HELLO WORLD");
	       getch();
	       return 0;
	   }

How about

int colours[3] = { RED, YELLOW, BLUE };
textcolor(colors[rand()%3] + BLINK);

Now add a loop around that, perhaps more colours in the array and maybe even a gotoxy and you're done.

If you are going to do that then you don't need the BLINK attribute.

forever
   show text in color
   delay a few milliseconds
   erase text
   delay a few milliseconds
   generate another random color attribute
end of loop
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
int main()
{
int colors[3] = { RED, YELLOW, BLUE };{
textcolor(colors[rand()%3]+BLINK);
cprintf("HELLO WORLD");}
getch();
return 0;
}

OK HERE IS MY NEW CODE BUT I GOT ONE ERROR
FUNCTION 'RAND' SHOULD HAVE A PROTOTYPE
WHAT SHOULD I DO

rand() is prototyped in stdlib.h

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int main()
{
int colors[3] = { RED, YELLOW, BLUE };
textcolor(colors[rand()%3]+BLINK);
cprintf("HELLO WORLD");
getch();
return 0;
}

OK THIS IS WEIRD THE PROGRAM INITIATE
BUT IT IS ONLY IN ONE COLOR. WHAT IS WRONG IN
THIS CODE?? I HAVE NO IDEA.. THANKS FOR ALL THE REPLY

You failed to use a loop, as explained in this and this posts

.

commented: + for LOL (oops, that was caps,but it was a loud laugh) +17
commented: :) +15

Off topic: @bobytch writing posts all in capital letters is considered as shouting and very rude. So please take it in consideration when you post next time

commented: yes +17

There is no loop. So you randomize the color only once, that is why you see only one color.

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int main()
{
loop:
int colors[3] = { RED, YELLOW, BLUE };
textcolor(colors[rand()%3]+BLINK);
gotoxy(1,5)
cprintf("HELLO WORLD");
goto loop;
getch();
return 0;
}

ok here is my new code again with loop but i have problem again
when i initiate the changing of color was superfast what should i do
sorry for the capslock..

Ok This is solved i got i right thanks to everyone.....

move line 7 down one line so that the color array is not re-initialized on every loop iteration. And you can get rid of that awful goto statement.

int colors[3] = { RED, YELLOW, BLUE };
while(1)
{
    textcolor(colors[rand()%3]+BLINK);
    gotoxy(1,5)
    cprintf("HELLO WORLD");
    delay(100); // slow down the loop
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.