Page History
...
Code Block |
---|
#include <time.h> // time struct timespec start, stop; int gettimeStatus = clock_gettime( CLOCK_REALTIME, &start ); printf ( "gettimeStatus: %d \n", gettimeStatus ); printf ( "start.tv_sec = %d start.tv_nsec = %d \n", start.tv_sec, start.tv_nsec ); gettimeStatus = clock_gettime( CLOCK_REALTIME, &stop ); printf ( " stop.tv_sec = %d stop.tv_nsec = %d \n", stop.tv_sec, stop.tv_nsec ); printf ( " dt_sec = %d dt_nsec = %d \n", stop.tv_sec - start.tv_sec, stop.tv_nsec- start.tv_nsec); |
...
Direct access to command line parameters in C++
Code Block |
---|
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
cout << "argc = " << argc << endl;
for(int i = 0; i < argc; i++)
cout << "argv[" << i << "] = " << argv[i] << endl;
return 0;
}
|
Input parameters parsing with getopt
getopt has potential problem: it does not detect the missing argument and pick-up the next available option as an argument...
RETURN VALUE:
...
Overview
Content Tools