2021-01-30

Reading a file in Linux using C

I am attempting to open a file I have created called "inputs.txt" using ubuntu on Windows. In the Linux manual I found that the O_DIRECTORY flag is used for files in the same directory and will fail if they are not in that directory. I used this flag and saved the "inputs.txt" file in the same folder as my .c file. Any ideas why it is failing to open?

int main(){
    int fd;
    fd = open("inputs.txt", O_DIRECTORY);
    if (fd == -1){
        printf("Failed");
        exit(1);
    }
    return 0;
}


from Recent Questions - Stack Overflow https://ift.tt/36ncwm4
https://ift.tt/eA8V8J

No comments:

Post a Comment