1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
 
  | 
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <windows.h>
using namespace std;
void z()
{
    Sleep(500);
}
void homeCursor(HANDLE h)
{
    COORD home = { 0, 0 };
    SetConsoleCursorPosition(h, home);
}
int main()
{
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    std::srand((unsigned) std::time(0));
    char space = 32;                                   //char 32 is space
    const char a [] = {space, '>', '>', '>', '>', '\0' };
    const char b [] = {space, '>', '>', '>', '>', '\0'};
    const char* row [] = { a, b};
    const unsigned rows = 1;
    for (unsigned i = 0; i < 10; i++)
    {
        homeCursor(hConsole);
          if (i % 2)
        {
            int a = 6;
             SetConsoleTextAttribute (hConsole, a);
            for (unsigned j = 0; j < rows; ++j)
                std::cout << row[j % 2] << '\n';  //I want to somehow add more spaces as the loop continues
        }
        else
        {
            int b = 3;
             SetConsoleTextAttribute (hConsole, b);
            for (unsigned j = 0; j < rows; ++j)
                std::cout << row[1 - (j % 2)] << '\n';
        }
        std::cout << flush;
        z();
    }
}
  |  |