Anonymouse Posted April 3, 2010 Share Posted April 3, 2010 Believe it or not, I HAVE ACTUALLY MUSTERED THE PATIENCE TO PROGRAM A NEW C++ PROGRAM! It's basically a stopwatch. Start it and it counts up, hours, minutes, seconds, and milliseconds #include <iostream> #include <ctime> using namespace std; int main() { int total = 0; int h = 0, m = 0, s = 0, ms = 0; while ( true ) { total++; ms++; if (ms > 999) { ms = 0; s++; if (s > 59) { s = 0; m++; if (m > 59) { m = 0; h++; } } } cout << "\rtime: " << h << ":" << m << ":" << s << "." << ms; cout.flush(); usleep(1000); } cout << "\n"; return 0; } It should compile, if you get an error about usleep not existing, then your standard C library fails :P Link to comment Share on other sites More sharing options...
Anonymouse Posted April 3, 2010 Author Share Posted April 3, 2010 UPDATE: Warning. Accuracy is not guaranteed. Use at your own risk. Link to comment Share on other sites More sharing options...
TheDoctor Posted April 3, 2010 Share Posted April 3, 2010 xD Mouse, the purpose of a stopwatch is to accurately record time... you fail at programming if it can't do that right. Link to comment Share on other sites More sharing options...
TheEPICtrainrider Posted April 3, 2010 Share Posted April 3, 2010 What doc said. YOU FAIL AT C++. Link to comment Share on other sites More sharing options...
Anonymouse Posted April 3, 2010 Author Share Posted April 3, 2010 Not really... It's just a little bit slow because reprinting the data takes some time :/ Link to comment Share on other sites More sharing options...
Sharkly Posted June 5, 2010 Share Posted June 5, 2010 I'd like to see you guys do better! You'd probably FAIL at it to. Making a stopwatch in C++ is very difficult, believe it or not. Link to comment Share on other sites More sharing options...
Recommended Posts