p4.5.c

来自「《linux编程技术详解》 linux编程入门的好书」· C语言 代码 · 共 26 行

C
26
字号
#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int main(void){	char test;	int fd;	if((fd=open("test.dat",O_RDONLY))==-1){	    perror("Cannot open the test.dat file");	    return 1;	}	if(fork()==-1){	    perror("Cannot create the child process");	    return 1;	}	read(fd,&test,1);	printf("Process ID: %ld read the character: %c\n",(long)getpid(),test);        close(fd);	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?