Click here to Skip to main content
15,885,365 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Random Color Generator

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
15 Sep 2011CPOL 22K   4
Easy HTML random color generator code (in C++):srand (time(NULL));TCHAR rand_color[10];wsprintf (rand_color, L"#%02x%02x%02x", rand()%255, rand()%255, rand()%255);//rand_color is now a random html color code in text

Easy HTML random color generator code (in C++):


C++
srand (time(NULL));
TCHAR rand_color[10];
wsprintf (rand_color, L"#%02x%02x%02x", rand()%255, rand()%255, rand()%255);
//rand_color is now a random html color code in text

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 4 Good, but considering its C should... Pin
BrianBissell20-Sep-11 3:16
BrianBissell20-Sep-11 3:16 
GeneralA good point. I very rarely comment on CodeProject articles... Pin
flector15-Sep-11 11:23
flector15-Sep-11 11:23 
GeneralHello Flector, I think you should not create alternative fo... Pin
Eric Ouellet15-Sep-11 10:35
professionalEric Ouellet15-Sep-11 10:35 
GeneralThanks, you are right. This is the easiest method. But it di... Pin
Eric Ouellet15-Sep-11 10:10
professionalEric Ouellet15-Sep-11 10:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.