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