1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

I want function to count the time

Discussion in 'C' started by fulla, Mar 20, 2011.

  1. fulla

    fulla New Member

    hi..

    i want help for function that can count the time from start function to eand it ..

    in c++ thr is function but i never use it i want help how can i use it..
    thanks
     
  2. virxen

    virxen New Member

    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main ( ) {
    time_t t;
    clock_t start, end;
    long i,count= 100000000;
    
    start = clock();
    
    time(&t);
    
    printf(ctime(&t));
    printf( "Counting to %ld\n", count );
    
    for (i=0; i < count; i ++);
    
    end = clock();
    
    printf( "That took %f seconds and I counted up to %ld", (((double)(end-start)/CLOCKS_PER_SEC)), count );
    getchar();
    return 0;
    } 
    
     

Share This Page