C 언어: sleep 함수

C언어: 시간지연


/// 헤더파일

#include <unistd.h>

/// 함수원형

unsigned int sleep (unsigned int seconds);

/// 인자

unsigned int seconds: 1000000(1초)

/// 반환값

성공시 반환값(return value): 0

/// 참고파일

헤더파일: unistd.h(연결)
소스파일: sleep.c(연결)

reference
https://man7.org/linux/man-pages/man3/sleep.3.html

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <unistd.h>
 
int main(void) {
    int second;
 
    second = 5;
 
    printf("After %d seconds, it will end.\n\n", second);
 
    do {
        printf("%d : return value is %d\n", second, sleep(1));
                                                 // 1초간 지연시킴과 동시에 반환값 확인
        second--;
    } while(second > 0);
 
    return 0;
}
cs

* 실행환경: Linux(5.7.6-x86_64-linode136)
* 컴파일러: gcc (Ubuntu 6.5.0-2ubuntu1~14.04.1) 6.5.0 20181026


- 당신을 응원합니다. -

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수