열렬히.뛰기

시간 맞추기

école 42 > philosopher > philosopher : 진행 상황 > 시간 맞추기

시간 뽑아내기

get_time()이라는 함수를 사용

c
long    get_time(void)
{
    struct  timeval time;

    gettimeofday(&time, NULL);
    return ((time.tv_sec * (unsigned long)1000) + (time.tv_usec / 1000));
}

구조체 timeval은 다음과 같이 생겼다.

c
struct timeval
{
    long tv_sec;       // 초
    long tv_usec;      // 마이크로초
}