[Linux, C] cat명령어 만들기Linux2020. 10. 1. 20:58
Table of Contents
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define BUF_SIZE 256
int main(int argc, char *argv[]){
int fdin;
char *path = argv[1];
char buf[BUF_SIZE];
if(argc != 2){
printf("argc error \n");
exit(1);
}
fdin = open(path, O_RDONLY);
if(fdin == -1){
printf("open() error \n");
exit(1);
}
read(fdin, buf, sizeof(buf));
printf("%s", buf);
close(fdin);
return 0;
}
반응형
'Linux' 카테고리의 다른 글
[Linux,C] ls 명령어 만들기 (0) | 2020.10.15 |
---|---|
[Linux,C] 우분투 ifconfig설치, 에러 waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. 에러 해결 (0) | 2020.10.06 |
[Linux, C] echo 서버 & 클라이언트 TCP/IP 통신 (0) | 2020.09.14 |
[Linux, C] Hello world 서버 & 클라이언트 TCP/IP통신, 소켓통신 (0) | 2020.09.14 |
[Linux, C] IP주소와 도메인네임을 서로 치환하는 프로그램 TCP/IP통신 (0) | 2020.09.07 |
@반나무 :: 반나무_뿌리
3년차 WPF 개발자입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!