clock() keeps returning 0
I have spent entire days trying to figure out why my clock() function is seeming to only return 0,15, or 31(it returns 15 or 31 when i make int i a double. and i have no idea why this would change the time). it seems to not matter how many nested loops i have in my program either, it just returns the same values. I've tried adding to my i, and it does nothing(but after 10 chars my program seems to be stuck in an infinate loop). thanks for your time!
Code:
#include <stdio.h>
#include <time.h>
double getMilliseconds() {
return 1000.0 * clock() / CLOCKS_PER_SEC;
}
int main() {
int i;
double j;
double elapsed;
elapsed = -getMilliseconds();
j = 0;
for(i = 0; i < 100000000; ++i)
j = j + i / 3.0; /* nonsense computation that just takes time */
elapsed += getMilliseconds();
printf("Elapsed Milliseconds = %lf\n", elapsed);
return 0;
}