找回密码
 注册
查看: 567|回复: 0

??请教高手一个读写usb设备的编程问题!!

[复制链接]
发表于 2005-10-18 17:07:41 | 显示全部楼层 |阅读模式
// io.c
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

main (){
        int fd;
        int str[3];
        if ((fd=open("/dev/hiddev0",O_RDWR|O_CREAT,0600))<0)
        {
                perror("open");
                exit(1);
        }
        if (write(fd,str,3)<0)
        {
                perror("write");
                exit(1);
        }
}
/dev/hiddev0 是一个usb设备,但不是block设备
运行 gcc -o io io.c 没有提示什么东西
运行 ./io 出现错误 write: Invalid argument
为什么 ?怎么修改?谢谢!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-7 23:19 , Processed in 0.022771 second(s), 15 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表