zoukankan      html  css  js  c++  java
  • 文件IO函数

    creat函数创建一个新文件:

    #include <fcntl.h>
    int creat( const char *pathname, mode_t mode );

     返回值:若成功则返回为只写打开的文件描述符,若出错则返回-1;

     

    open 函数用于打开和创建文件:
    #include <fcntl.h>
    int open(const char *pathname, int oflag, ... /* mode_t mode */);
    返回值:成功则返回文件描述符,否则返回 -1

     

    close函数关闭一个打开的文件:

    #include <unistd.h>
    int close( int filedes );

    返回值:若成功则返回0,若出错则返回-1;

     

    lseek函数为一个打开的文件设置其偏移量:

    #include <unistd.h>
    off_t lseek( int filedes, off_t offset, int whence );

    返回值:若成功则返回新的文件偏移量,若出错则返回-1;

     

    read函数从打开文件中读数据:

    #include <unistd.h>
    ssize_t read( int filedes, void *buf, size_t nbytest );

    返回值:若成功则返回读到的字节数,若已读到文件结尾则返回0,若出错则返回-1;

     

    write函数向打开的文件写数据:

    #include <unistd.h>
    ssize_t write( int filedes, const void *buf, size_t nbytes );

    返回值:若成功则返回已写的字节数,若出错则返回-1。

  • 相关阅读:
    SQL Server 文件操作
    约束5:外键约束
    SSIS 对数据排序
    列属性:RowGUIDCol、Identity 和 not for replication
    TSQL 数据类型转换
    HierarchyID 数据类型用法
    租房那些事
    SSIS 延迟验证
    SQL Server 管理全文索引
    SQL Server 全文搜索
  • 原文地址:https://www.cnblogs.com/hezhangyear/p/4021216.html
Copyright © 2011-2022 走看看