Skip to content
Snippets Groups Projects
Commit b4097fe4 authored by 이장원's avatar 이장원
Browse files

8.3

parent 3ba3fab0
No related branches found
No related tags found
No related merge requests found
# printf
`int printf(const char *format, ...)`
printf 함수는 매개변수를 format에 따라서 출력해주는 함수다.
`int fprintf(FILE *stream, const char *format, ...)`
printf 함수는 실행될 때 내부에서 fprintf 함수로 바뀌어서 실행된다.
```
printf("Hello World")
fprintf(stdout, "Hello World")
```
printf 함수가 fprintf 함수로 바뀔 때 stream에 stdout이 들어가게 되고 두 함수는 완전히 같은 역할을 한다.
# stdio.h
standard input output library의 줄임말로 표준 입출력과 관련된 함수, 매크로 등이 포함된 헤더 파일이다.
## stream
* stdin
표준 입력 스트림(키보드)를 참조하는 FILE에 대한 포인터
* stdout
표준 출력 스트림(스크린)를 참조하는 FILE에 대한 포인터
* stderr
표준 오류 스트림(스크린)를 참조하는 FILE에 대한 포인터
# man
`man <command | function | header file | ...>`
manual의 줄임말로 명령어나 함수, 헤더 파일 등에 대한 사용법을 알려주는 명령어다.
# redirection
redirection이란 스트림의 흐름을 바꿔주는 것이다. redirection을 이용해 프로세스의 스트림을 콘솔이 아닌 파일을 사용할 수 있다.
* \> file
표준 출력을 파일로 redirection한다. 파일이 없으면 새로 만들고, 파일이 있으면 덮어쓴다.
```
$ ./test > output_data
```
* \>> file
표준 출력을 파일로 redirection한다. 파일이 없으면 새로 만들고, 파일이 있으면 파일의 끝에 덧붙인다.
```
$ ./test >> output_data
```
* < file
파일로부터 표준 입력을 받도록 redirection한다.
```
$ ./test < intput_data
```
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment