Hey guys, I was wondering if anyone could help me with a quick question.
I need to find a way to print the time it took for a program to run in seconds. I don't have much experience with time, but here's what I have so far:
Code:
void printSolution(int, time_t, time_t);
...
int main() {
int numrows = 0, numcols = 0;
time_t time1, time2;
time(&time1);
getInput(&numrows, &numcols);
time(&time2);
printSolution(numcols, time1, time2);
}
...
void printSolution(int numcols, time_t time1, time_t time2) {
int i;
printf("Solution Vector: ");
for (i=0; i<numcols;i++) printf("%d", solution[i]);
printf("\n");
printf("Time Taken: %d\n", difftime(time1, time2));
}
I included <time.h> at the top of the function and the output I get when I run it is currently:
"Solution Vector: 000000
Time Taken: 1195078298"
I can't quite seem to figure out what this is currently doing. Can anyone help me out?