分页: 1 / 1

以只写方式打开设备时失败?????为什么????

发表于 : 2008-06-10 17:34
sophiazhang
以只读方式打开时可以,以只写方式打开设备就失败,为什么??是因为权限问题吗??????
/*以只读方式打开设备*/

f=open("/home/sophiazhang/桌面/5/mychardev",0);

/*以只写的方式打开设备*/
f=open("/home/sophiazhang/桌面/5/mychardev",1);
/*判断打开是否成功,f>=0表示成功,否则表示失败*/
if(f>=0)
{
printf("The open operation to write succeed! \n");
}
else
{
printf("The open operation to write failed! \n");
return 0;

终端显示:
The open operation to read succeed!
How many chars do you want to read:(1-80)80
The operation to read succeed!
The actual number of chars which has been read is 28
Welcome to use this device.

The open operation to write failed!
}

发表于 : 2008-06-10 17:36
sophiazhang
如何解决这一问题呢?