Sunday, July 12, 2009

How can I use the function time() in a C++ code???

I want to get the running time of a C++ code ..how can I use the time() function ?? are there any other function that can do the same thing??

How can I use the function time() in a C++ code???
Hmm, that might have been confusing, here's a better example:





#include %26lt;time.h%26gt; // you'll need this for the time_t type





static void main( int argc, char * argv[] )


{


time_t currentTime;


currentTime = time( %26amp;currentTime );


}





Note that some libraries let you get away with calling time like:


time(NULL);


or even:


time();





In any case, the end result is a long int of type time_t which can be used in a variety of ways, but is actually the number of seconds since 12am Jan 1st, 1970 GMT.

chrysanthemum

No comments:

Post a Comment