Well you don't want to use duration like that to control the loop, because you'll go out of the array bounds (besides, it wouldn't be basing it on time)
You want to cycle through the array (index: 0,1,2,3,0,1,2,3,etc) and exit the loop when a certain time has gone by (look at the clock() function in time.h maybe)
Edit: Too slow, here's my solution:
#include
#include
void Sleep(double time)
{
clock_t start = clock();
while ((clock()/(double)CLOCKS_PER_SEC)<((start/(double)CLOCKS_PER_SEC)+time));
}
void spinny_thingy (long duration)
{
int i;
char spinner[] = "|/-\\";
clock_t start = clock();
for (i = 4;(clock()/(double)CLOCKS_PER_SEC)<((start/(double)CLOCKS_PER_SEC)+duration); i++) {
putchar (spinner[i%4]);
putchar ('\b');
fflush (stdout);
Sleep(.5);
}
}
int main()
{
spinny_thingy(10);
}