Difftime problem

Hello all

I am currently writing a program where I need to know how long it takes for it to do a loop so that I might optimise it. For that purpose I have found the example in difftime here on the site and tried to follow its example.
My code looks like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <time.h>
int main(void) 
{
time_t t1, t2; 
double dif; 

time(&t1)

//for loop 

time(&t2);
dif = difftime(t2,t1);

cout << "This took"<< dif << "seconds" << endl; 
}


If I remove the loop it correctly says "This took0seconds"
If I put in any loop I get a compile error "error: expression must have (pointer-to-) function type" for the two lines with time() in them.

All examples I can find online about difftime shows this way of doing it so I am at a loss why it does not work.
I use the g++4.3 compiler.
Thanks in advance for any help!
return something? I don't see why you can't have a loop...
How does the loop look like?

Okay embarrassing, the problem was because I had an array called time, I had not realised that the two would conflict.
I apologise for the inconvenience!

Topic archived. No new replies allowed.