首页 > 代码库 > 04clock_01misc_app_write

04clock_01misc_app_write

 1 #include <stdio.h> 2 #include <sys/stat.h> 3 #include <fcntl.h> 4 #include <unistd.h> 5  6 #define DEV_NAME "/dev/my_led" 7  8 int main(int argc, char const *argv[]) 9 {10     11     int  fd = open(DEV_NAME, O_RDWR);12     if(fd < 0) {13         perror("open");14         return -1;15     }16 17     char buf[10] = "1234567890";18 19     //int ret = read(fd, buf, 10);20     //printf("buf = %s\n", buf);21 22     write(fd, buf, 10); 23 24     close(fd);25     return 0;26 }

 

04clock_01misc_app_write