zoukankan      html  css  js  c++  java
  • Linux学习之路4——文件IO打开、创建、读写操作

    1、使用man 2 open、man 2 creat、man 2 write、man 2 read命令获取头文件

      语法:

    int open(const char *pathname, int flags);//pathname:路径名,flags:O_RDONLY 只读,O_WRONLY 只写,O_RDWR 可读可写,O_NOCTTY如果路径指向终端,则不将设备作为此进程的控制终端 ,O_NDELAY非阻塞 。错误返回-1
    int open(const char *pathname, int flags, mode_t mode);//mode:文件权限。错误返回-1 int creat(const char *pathname, mode_t mode);//参数含义同上。错误返回-1

        ssize_t read(int fd, void *buf, size_t count);//fd:句柄,*buf:读出的数据缓存,最多读的字节数。错误返回-1,正确返回读取字节数

        ssize_t write(int fd, const void *buf, size_t count);//fd:句柄,*buf:要写入的数据,count,要写入的最大字节数。错误返回-1,正确返回写入字节数

    2、拷贝到Ubuntu中,在Ubuntu中编译

    3、编译文件拷贝到U盘中

    4、烧写流程参考上一篇文章

  • 相关阅读:
    第八章 多线程编程
    Linked List Cycle II
    Swap Nodes in Pairs
    Container With Most Water
    Best Time to Buy and Sell Stock III
    Best Time to Buy and Sell Stock II
    Linked List Cycle
    4Sum
    3Sum
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/syj888/p/10583744.html
Copyright © 2011-2022 走看看