读书人

linux驱动open函数有关问题大家来看

发布时间: 2012-03-24 14:00:46 作者: rapoo

linux驱动open函数问题,大家来看看(我没有分,所以给的少点)
这是我的程序

#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

using namespace std;

int main() {
int fd;

fd=open( "/dev/lp0 ",O_RDWR);
if(fd==-1)
{
cout < < "can 't open file " < <endl;
cout < < "fd: " < <fd < <endl;
//exit(0);
}
else
{
cout < < "nihao " < <endl;
}
close(fd);
return 0;
}
总是输出can 't open file ,打不开lp0,这是怎么回事,大家帮忙看看。

[解决办法]
root# mknod /dev/lp0 c 6 0

读书人网 >UNIXLINUX

热点推荐