c++ rainbow text
C++
`enter code here`#include <stdafx.h> // Used with MS Visual Studio Express. Delete line if using something different
#include <conio.h> // Just for WaitKey() routine
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); // For use of SetConsoleTextAttribute()
void WaitKey();
int main()
{
int len = 0,x, y=240; // 240 = white background, black foreground
string text = "Hello World. I feel pretty today!";
len = text.length();
cout << endl << endl << endl << "\t\t"; // start 3 down, 2 tabs, right
for ( x=0;x<len;x++)
{
SetConsoleTextAttribute(console, y); // set color for the next print
cout << text[x];
y++; // add 1 to y, for a new color
if ( y >254) // There are 255 colors. 255 being white on white. Nothing to see. Bypass it
y=240; // if y > 254, start colors back at white background, black chars
Sleep(250); // Pause between letters
}
SetConsoleTextAttribute(console, 15); // set color to black background, white chars
WaitKey(); // Program over, wait for a keypress to close program
}
void WaitKey()
{
cout << endl << endl << endl << "\t\t\tPress any key";
while (_kbhit()) _getch(); // Empty the input buffer
_getch(); // Wait for a key
while (_kbhit()) _getch(); // Empty the input buffer (some keys sends two messages)
}
Also in C++:
- Title
- function for searching in map in c++
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- namespace c++
- Category
- C++
- Title
- advanced c++ topics
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- % operator in c++
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- c++ pointers
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- phph date
- Category
- C++
- Title
- flake8 max line length
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- size of a matrix using vector c++
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- how to check type in c++
- Category
- C++
- Title
- apple and orange hackerrank solution in c++
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- how to get the largest number in a c++ array
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- char size length c++
- Category
- C++
- Title
- subarray sum in c++
- Category
- C++
- Title
- c++ lettura file
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- how the theam are store in database
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- initialising 2d vector
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- two sum problem in c++
- Category
- C++
- Title
- peak in c++
- Category
- C++
- Title
- run program until ctrl-d c++
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- c++ main function
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- how to check sqrt of number is integer c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- int random string generator c++
- Category
- C++
- Title
- number of islands leetcode code
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- how to modulo 10^9+7
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- c++ vector iterator
- Category
- C++
- Title
- lopping over an array c++
- Category
- C++
- Title
- initialize vector of pointers c++
- Category
- C++
- Title
- print type cpp
- Category
- C++
- Title
- initialize map c++
- Category
- C++
- Title
- caesar cipher program in c++
- Category
- C++
- Title
- ue4 c++ struct
- Category
- C++
- Title
- making random numbers in c++
- Category
- C++
- Title
- differentialble programming
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- how to write an or in c++
- Category
- C++
- Title
- c++ method name
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- clear qlayout
- Category
- C++
- Title
- visual studio 2019 read and write text file c++
- Category
- C++
- Title
- 2927260.eps 2927262.jpg 2927263.ai License free.txt License premium.txt
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- function template
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- c++ compiler for sublime text
- Category
- C++
- Title
- calling a method on an object c++
- Category
- C++
- Title
- passing array to function c++ pointer
- Category
- C++
- Title
- for loop
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- matrix transpose tiling
- Category
- C++
- Title
- primeros numeors primos menores que
- Category
- C++
- Title
- chess perft 5
- Category
- C++
- Title
- mkdir c++
- Category
- C++
- Title
- user input c++
- Category
- C++
- Title
- never gonna give you up
- Category
- C++
- Title
- multiset c++
- Category
- C++
- Title
- Rectangle area hackerrank solution in c++
- Category
- C++
- Title
- insert elements in array in c++11
- Category
- C++
- Title
- how to convert int to string c++
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- uepic games github
- Category
- C++
- Title
- c++ clear stream
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- modular exponentiation c++
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- iterative inorder traversal
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- pow c++
- Category
- C++
- Title
- how to get os name in c++
- Category
- C++
- Title
- how to put a class in a .h file c++
- Category
- C++
- Title
- array as parameter c++
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- get index of value c++
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++