#include "stdafx.h"
#include <iostream>
#include <string>
#include <windows.h>
#include <time.h>
unsigned long n = 1;
int main()
{
int i = 0;
std::string text = "I whip my hair back and forth";
std::string wipIt = " ";
size_t sz;
sz = wipIt.size();
srand(time(0));
do{
for(i = 0; i < 10; i++)
{
int randomNumber = rand() % 15 + 1;
Sleep(50);
wipIt.resize (sz++,' ');
std::cout << wipIt;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), randomNumber);
std::cout << text << "\n";
}
for(i = 10; i > 0; i--)
{
int randomNumber = rand() % 15 + 1;
Sleep(50);
wipIt.resize (sz--,' ');
std::cout << wipIt;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), randomNumber);
std::cout << text << "\n";
}
}
while (n != 0);
return 0;
}
If I messed this post up I apologize this is only like my second post.
What would be the easiest way to make every character in the string a different color, instead of the entire string the same color.
Tidying up tips would be appreciated as well :P
EDIT: tidy'd up a little, and the random is working well, thank you all ^_^ now for the color by character?