文件IO

#include "unistd.h"
#include "fcntl.h"
#include <iostream>
using namespace std;

int main()
{
    int fd = open("test.txt",O_RDWR | O_CREAT  | O_APPEND);
    if(write(fd,"test",4)!=4){
        cout << "error" << endl;
    }
    close(fd);

    int newFd = dup(1);
    cout << "当前系统最小的fd:" << newFd << endl;
}

当前系统最小的fd:3

你可能感兴趣的:(IO)