"c++ rainbow text" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "c++ rainbow text" answered properly. Developers are finding an appropriate answer about c++ rainbow text related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like c++ rainbow text. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on c++ rainbow text. 

c++ rainbow text

By Repulsive RookRepulsive Rook on Jul 02, 2020
`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)
}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the C++ based application and are stuck on c++ rainbow text can get a collection of related answers to their query. Programmers need to enter their query on c++ rainbow text related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c++ rainbow text for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of c++ rainbow text while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "c++ rainbow text". Visit this developer's friendly online web community, CodeProZone, and get your queries like c++ rainbow text resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "c++ rainbow text"

View All C++ queries

C++ queries related to "c++ rainbow text"

Browse Other Code Languages

CodeProZone