일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 가상메모리 관리
- MYSQL
- 딕셔너리
- 그리디
- 가상메모리
- level0
- BOJ
- 다익스트라
- 프로그래머스
- BFS
- 백준
- 구현
- 재귀
- 파이썬
- 다이나믹 프로그래밍
- 운영체제
- DP
- level1
- 코딩테스트
- level2
- python
- dfs
- 수학
- 스택
- 브루트포스
- level3
- N과M
- programmers
- 에라스토테네스의 체
- 힙
- Today
- Total
목록CS (49)
동캄의 코딩도장
Ascii(text) file -사람이 바로 읽을 수 있음 - 데이터 저장 및 사용 시, 문자로 (or 문제에서) 변환 과정이 필요함 --> 많은 양의 데이터 처리에 비효율적 --> 동일한 데이터를 저장하는 이진 파일대비 많은 공간을 요구함 Binary file - 컴퓨터가 바로 사용할 수 있는 형태(메모리에 저장된 형태 그대로 저장) --> 별도의 변화 과정 없이 읽기/쓰기 가능 ---> 데이터 처리에 효율적이며, 저장 공간을 효율적으로 사용 할 수 있음 - 사람이 읽을 수 없는 형태--> 데이터 교환 시 약속(protocol)이 필요함 Binary File Binary I/O FILE *fopen (cont char *name, const char *mode) mode - "rb", "wb", "ab..
Character-based reading #include int fgetc (FILE * stream); int getc (FILE * stream); int getchar (void); stream: File operation을 수행할 stream c (character): 쓰려는 문자 Return: 읽은/기록한 문자 | EOF(-1) : error Character-based reading #icclude int fputc (int c, FILE *stream); int putc (int c, FILE *stream); int putchar(int c); stream: File operation을 수행 할 stream c(character): 쓰려는 문자 Return - 읽은/기록한 문자 | EOF..
Standard IO - A platform-independent, user-buffering solution File pointer - File operation을 관리하는 구조체(FILE)을 가리키는 포인터 - 내부적으로 file descriptor와 연동(mapping)됨 Stream - 프로그램과 file을 연결한 통로 Workflow of file I/O File open -> File access (Read/ Write) -> File close FIle open (Opening a file/stream) #include FILE *fopen (const char *path, const char *mode); path (file path) - 열려는 파일의 경로 mode (file open m..
High-Level File IO (Buffered IO) Disk address physical disk address - sector(물리적 데이터 전송 단위)를 지정 Logical disk address: relative address - Disk system의 데이터 전체를 block들의 나열로 취급 (block에 번호 부여, 임의의 block에 접근) - Block 번호 -> physical address 모듈 필요 (disk driver) Block - An abstraction of the file system - 운영체제(예, linux) 입장에서 file system은 block들의 나열 - 512~8192 byte(2^n) - Disk (or block device) access의 최소..
System calls for fileIO Duplicating FD - dup(2) /dup2(2) #include int dup (int oldfd); int dup2 (int oldfd, int newfd); oldfd (old file descriptor) - 복사하려는 file descriptor newfd (new file descriptor) - 새로운 fd 지정 - dup()의 경우 할당 가능한 fd중 가장 작은 값 할당 Return: oldfd를 복사한 새로운 fd (-1: error) Manipulating FD - fcntl(2) #include #include int fnctl (int fd, int cmd, /* arg*/ ...); fd (file descriptor) - 대상 ..
파일 읽기/쓰기 (File read and write) Reading a fiel - read(2) ex) #include ssize_t read ( int fd, void *buf , size_t count); fd (file descriptor) - 읽으려는 파일의 file descriptor buf (buffer) - 읽은 내용을 저장할 buffer의 시작 주소 count - 읽을 byte의 수 Return: 실제로 읽은 byte의 수( 0: 파일 끝에 도달, -1: 에러) Writing to a file - write (2) #include ssize_t write (int fd, const void *buf, size_t count); fd (file descriptor) - 기록하려는 파일의 ..