查询的标签:


Linux下由两个管道提供双向数据流的C程序

标签: , and

以下是一个Linux/Unix下由两个管道提供双向数据流的C程序,这是操作系统课程中经常使用的基本程序:
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <string.h>
int main()
{
    int fd1[2],fd2[2],cld_pid,status;
    char buf[200], len;
 
    if (pipe(fd1) == -1) // 创建...

1 Comment »

Linux下显示某一目录下文件名列表的C程序

标签: , and

以下是一个Linux/Unix下显示某一目录下文件列表的C程序,相当于最基本的ls命令的功能,显示的内容报告该目录下的子目录以及文件名:
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
int main(int argc,char *argv[])
{
    DIR *dp;
    struct dirent *dirp;
    int n=0;
    if (argc!=...

2 Comments »