1 #include <stdio.h>
2 #include <dirent.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #define BUFSIZE 256
6
7 int main(int argc,char **argv)
8 {
9 char buffer[BUFSIZE] = {0};
10 ssize_t nread;
11 //FILE *fp;
12 int fdin;
13
14 if(!(fdin = open("/home/korea/seoul", O_RDONLY , 0644))){
15 perror("open() error");
16 return -1;
17 }
18
19 while((nread = read(fdin,buffer,256))>0) {
20 printf("%s",buffer);
21 }
22 close(fdin);
23 return 0;
24 }
1.디렉토리를 열어서 그 파일안에 내용을 출력하게 만들었는데 아무것도 안되네요..? 머가 문제인가요?
2.+ 만약 파일을 3개씩 출력하고싶으면 어떤걸 써야 될까요?
ex
a.file b.file c.file
x.file y.file z.file
이런식으로요
댓글 0