Countdown problem.

I'm attempting to create a countdown timer. Which basically works its way down from 10 to 0. I'm trying to make it so when the variable == a certain number it will change the color of the program.
code is not fully mine, but I don't know how to fix this,
i'm in a rush and throw all complete details like my includes or anything right now. The wait() and setconsole, and colors are all borrowed from codes from this site.
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
int main()
{
	/*char str[] = "X";
	memset (str,'-',6);*/

	string username = "NULL";
	string admstatus = "NULL";
	string password = "NULL";

	   SetConsoleTitle(title);//the console title
	   
	   if (loadeded <= 0)
	   {
		   	  time();
	cout << loadx1;
	loadeded++;

	   }
	   else if (loadeded == 1)
	   {
//nothing
	   }
	   else
	   {
		cout << errorset;
	   }
		   cin.ignore(100, '\n');
		     clr();

	string bat;
	//color stuff:
	const WORD colors[] =
		{
		0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,//Note to self: Check what all these colors are...Aka what are all the color combos.
		0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6
		};
	HANDLE hstdin  = GetStdHandle( STD_INPUT_HANDLE  );
	HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
	WORD   index   = 0;

	CONSOLE_SCREEN_BUFFER_INFO csbi;
	GetConsoleScreenBufferInfo( hstdout, &csbi );
//:

   string admnstatus;
   string strPath;
   strPath = argon;
//cout << "                                               \n";// TEMPFIX; I don't like all dat blue, fix it.
 if (_access( strPath.c_str(), 0 ) == 0 ) //You will see this often, it checks if the folder U exists. Pretty Awesome.
 {
     struct stat status;
     stat( strPath.c_str(), &status );
          if ( status.st_mode && S_IFDIR )
          {
       string admstatus = "0"; //Admin Status has to be 0... Yeah I don't remember why I put that in here.
		loginpt1(admnstatus);
          }

          else
          {
          cout << pathexistfile << endl; //folder u does not exists
         foldercreation();
          }

 }

  else
   {
cout << dirnoexist << endl; //folder u does not exists
         foldercreation();
 }
}
void clearpause()
{
cin.ignore(100, '\n');
}

void wait (int seconds)
{
  clock_t endwait;
  endwait = clock () + seconds * CLOCKS_PER_SEC * .5 ;
  while (clock() < endwait) {}
}

If you have ever done anything like this or you can refer me to a different thread or website with a solution. Please lead me in the correct direction. Thank you.

1
2
3
4
5
6
for (unsigned i = 0; i < 10; ++i) {
 Sleep(1000);
 cout << "Beep" << end;

 setColour(i);
}


Of course you will need to write a setColour method that takes an int argument and changes the colour based on that index into the array. But that is the easiest way to make something count down over a static period of time without launching a new thread.
Topic archived. No new replies allowed.