I am making a program that shows a number then after a few seconds it should erase it having the player remember it the type it in but i dont know how to get it to erase the numbers after lets say, 5 seconds or so. I really dont want to use winapi unless absolutley necessary. how would i do this?
#include <iostream>
#include <cstdlib>
#include <ctime>
int main()
{
time_t T, U;
time (&T);
time (&U);
srand(T);
int X = rand() % 1000;
std::cout << X;
while (U - T < 5)
time(&U);
std::cout << "\b\b\b\b" << std::endl;;
}
I believe your last line should be.. std::cout << "\b\b\b\b " << std::endl;// four spaces
otherwise, the cursor would only start at the beginning of the line, but would not be erased.