Skip to content

Instantly share code, notes, and snippets.

@jonathan-beard
Last active August 29, 2015 14:03
Show Gist options
  • Save jonathan-beard/bb9691e0b1f2775d4e27 to your computer and use it in GitHub Desktop.
Save jonathan-beard/bb9691e0b1f2775d4e27 to your computer and use it in GitHub Desktop.
#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 );
}
@jonathan-beard
Copy link
Author

fixed file extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment