github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example-c-hello/hello.c (about)

     1  /*
     2  #include <sys/time.h>
     3  #include <stdlib.h>
     4  #include <stdio.h>
     5  #include <math.h>
     6  
     7  int Fibonacci(int n)
     8  {
     9     if ( n < 2 )
    10        return n;
    11     else
    12        return ( Fibonacci(n-1) + Fibonacci(n-2) );
    13  } 
    14  
    15  // Return 1 if the difference is negative, otherwise 0. 
    16  int timeval_subtract(struct timeval *result, struct timeval *t2, struct timeval *t1)
    17  {
    18      long int diff = (t2->tv_usec + 1000000 * t2->tv_sec) - (t1->tv_usec + 1000000 * t1->tv_sec);
    19      result->tv_sec = diff / 1000000;
    20      result->tv_usec = diff % 1000000;
    21  
    22      return (diff<0);
    23  }
    24  
    25  void timeval_print(struct timeval *tv)
    26  {
    27      char buffer[30];
    28      time_t curtime;
    29  
    30      printf("%ld.%06ld", tv->tv_sec, tv->tv_usec);
    31      curtime = tv->tv_sec;
    32      strftime(buffer, 30, "%m-%d-%Y  %T", localtime(&curtime));
    33      printf(" = %s.%06ld\n", buffer, tv->tv_usec);
    34  }
    35  
    36  int main()
    37  {
    38      struct timeval tvBegin, tvEnd, tvDiff;
    39  
    40      // begin
    41      gettimeofday(&tvBegin, NULL);
    42      timeval_print(&tvBegin);
    43  
    44      // lengthy operation
    45      int n = 46;
    46      printf("fibonacci number %d is: %d\n", n, Fibonacci(n) );
    47  
    48      //end
    49      gettimeofday(&tvEnd, NULL);
    50      timeval_print(&tvEnd);
    51  
    52      // diff
    53      timeval_subtract(&tvDiff, &tvEnd, &tvBegin);
    54      printf("%ld.%06ld\n", tvDiff.tv_sec, tvDiff.tv_usec);
    55  
    56      return 0;
    57  }
    58  */
    59  
    60  #include <stdio.h>
    61  
    62  int main(){
    63  	printf("hihi\n");
    64  }