how to do a stopwatch in a C++ program

hi how do you make it so it does like here it starts the stop watch and then runs whatever code then you stop the timer. I know how to find it out if you have a window open but how do you do it with the main thing.

thanks this is really helpful and cyberfish I am sure the commands you are talking about you would use the same way as mike_g's idea (wich by the way is really goodand I am thankful for it) you would make a variable the current time and then later on print the the new current time - the variable with the old time. I am yet to try it with cyberfish's method and I will try it in a moment.

note that the clock() function mike_g suggested is implementation specific. It can either measure real time (wall time) or CPU time. If I remember correctly, on Windows it measures real time, while on Linux it measures CPU time (don't know what happens on the Mac, but I would guess it's going to be the same as Linux since they are both POSIX and both use gcc). Therefore, it is ambiguous and I recommend against it.