Last active
August 29, 2015 14:03
-
-
Save jonathan-beard/bb9691e0b1f2775d4e27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <iostream> | |
#include <cstring> | |
#include <time.h> | |
int | |
main( int argc, char **argv ) | |
{ | |
struct timespec curr_time; | |
std::memset( &curr_time, | |
0, | |
sizeof( struct timespec ) ); | |
if( clock_gettime( CLOCK_REALTIME, &curr_time ) != 0 ) | |
{ | |
perror( "Failed to get time!\n" ); | |
} | |
std::cout << "Seconds: " << curr_time.tv_sec << "\n"; | |
std::cout << "Nanoseconds: " << curr_time.tv_nsec << "\n"; | |
std::cout << "Combined: " << | |
(double) curr_time.tv_sec + ((double) curr_time.tv_nsec * 1.0e-9 ) << "\n"; | |
return( EXIT_FAILURE ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed file extension