시스템 프로 그래 밍 인원 은 파이프 프로 그래 밍 을 배 워 야 한다.
링크:http://cs.usfca.edu/~cruse/cs635/
이 프로그램의 내용 은:
//-------------------------------------------------------------------
// mycat.c
//
// This program shows how the default behavior of the standard
// UNIX/Linux 'cat' command could readily be implemented in C.
// (Consult the 'man' page for 'cat' to see the 'options' that
// would need to be added to achieve a total 'cat' emulation.)
//
// compile using: $ gcc mycat.c -o mycat
// execute using: $ ./mycat <filename>
//
// programmer: ALLAN CRUSE
// written on: 24 AUG 2007
//-------------------------------------------------------------------
#include <fcntl.h> // for open()
#include <stdio.h> // for perror()
#include <unistd.h> // for read(), write(), close()
int main( int argc, char *argv[] )
{
int i, fd, ch; // declare local variables
for (i = 1; i < argc; i++)
{
fd = open( argv[i], O_RDONLY );
if ( fd < 0 ) { perror( argv[i] ); continue; }
while ( read( fd, &ch, 1 ) == 1 )
write( STDOUT_FILENO, &ch, 1 );
close( fd );
}
}
그 중에서 read 가 받 은 내용 을 표준 출력 으로 출력 할 때 write (STDOUT FILENO, & ch, 1) 를 사용 하고 출력 을 특정한 파일 로 재 설정 할 수 있 습 니 다.
pcie 데이터 전송 프로그램 을 작성 할 때 10 진법 으로 받 은 것 을 문자 로 변환 해서 파일 에 저장 하 는 것 이 생각 났 습 니 다. 여 기 는 STDOUT 로 출력 한 다음 에 파일 로 다시 설정 하면 목적 을 달성 할 수 있 을 것 같 습 니 다.이것 이 바로 풋내기 가 기본 시스템 프로 그래 밍 을 모 르 는 비극 이다. 너무 많은 시간 이 걸린다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.