#include <stdio.h>
#include <time.h>
#include<iostream>
using namespace std;
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main ()
{
int n;
int minutes = 0;
int hours = 0;
printf ("Starting countdown...\n");
for (n=0; n<=60; n++)
{
//printf ("%d\n",n);
wait (1);
if(n == 60)
{
minutes += 1;
n = 0;
}
if(minutes == 60)
{
hours += 1;
}
cout<<hours<<":"<<minutes<<":"<<n<<endl;
}
printf ("FIRE!!!\n");
system("pause");
return 0;
}
Creating a clock in Dev C++
Page 1 of 11 Replies - 5110 Views - Last Post: 12 May 2010 - 09:54 PM
#1 Guest_Guest*
Creating a clock in Dev C++
Posted 12 May 2010 - 09:24 PM
Why hello there. As the title implies, I'm trying to create a clock in Dev C++. It works fine but I don't want the cout<<hour<<":"<<minutes<<":"<<n<<endl; part to keep displaying. I want the seconds, minutes, and hours to iterate accordingly but I don't want the cout statement to keep repeating itself. What can I do to fix this?
Replies To: Creating a clock in Dev C++
#2
Re: Creating a clock in Dev C++
Posted 12 May 2010 - 09:54 PM
Use the Windows API to set the cursor position. Move the cursor around to overwrite the displayed numbers as needed.
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote







|