我正在尝试编写一个C程序,其中使用mknod命令,如下所示:
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
char info[50];
main() {
int fdr;
int rc = mknod("testfile",'b',0);
if(rc<0) {
perror("Error in mnod");
}
fdr=open("testfile",O_RDONLY);
read(fdr,info,50);
printf("\n Received message=%s",info);
printf("\n");
}
并且做一些事情。它在Red Hat系统上运行良好,但在Ubuntu上出现无效参数错误。