C语言,小小时间函数也出错,求解释
#include <stdio.h>#include <stdlib.h>
#include <time.h>
void sleep( long wait ){
long goal;
goal = wait + clock();
while( goal > clock() );
}
main(){
int i;
char *wday[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
time_t timep;
struct tm *p;
time(&timep);
for(i=0;i<10;i++){
p = localtime(&timep);
printf ("%d%d%d ", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday);
printf("%s %d:%d:%d\n", wday[p->tm_wday], p->tm_hour, p->tm_min, p->tm_sec);
sleep(30);
}
getch();}
这是我写的时间函数,但是显示的10个时间都是相同的,按理说应该会变化才对的??为什么呢??