- #include<stdio.h>
- #include<process.h>
- #include<time.h>//time.h header file
- intmain ()
- {
- int begin, end; //define start and end flags
- begin=clock(); //Start timing
- end=clock(); //end timing
- printf( "%d\n" , end-begin); //The difference is time, in milliseconds
- system("pause");
- return 0;
- }
Use the clock() function included in time.h to calculate the running time of a piece of code.
The time.h header file has a lot more to explore.