Answered You can hire a professional tutor to get the answer.

QUESTION

I get two errors with the following code, when compiled in UNIX: PLEASE FIX for good rating! #includelt;stdio.hgt; #includelt;fcntl.hgt;...

I get two errors with the following code, when compiled in UNIX: PLEASE FIX for good rating!

#include<stdio.h>

#include<fcntl.h>

#include<sys/stat.h>

#include<sys/types.h>

#include<stdlib.h>

int main()

{

int ret = 0;

int fd1 = 0, fd2 = 0;

//Creating main directory named "A4PART1"

ret = mkdir("./A4PART1",0766);

if(ret != 0){

fprintf(stderr,"Unable to create directory "A4PART1"n");

perror("A4PART1: ");

return -1;

}

//Creating folder1 inside A4PART1

ret = mkdir("./A4PART1/folder1",0766);

if(ret != 0){

fprintf(stderr,"Unable to create directory "folder1"n");

perror("Folder1: ");

return -1;

}

//Creating folder2 inside A4PART1

ret = mkdir("./A4PART1/folder2",0766);

if(ret != 0){

fprintf(stderr,"Unable to create directory "folder2"n");

perror("Folder2: ");

return -1;

}

//Creating file1.txt inside folder1

fd1 = open("./A4PART1/folder1/file1.txt",O_CREAT, 0644);

if(fd1 < 0){

fprintf(stderr,"Unable to create file1.txtn");

perror("File1: ");

return -1;

}

//Creating file2.txt inside folder2

fd2 = open("./A4PART1/folder2/file2.txt",O_CREAT, 0644);

if(fd2 < 0){

fprintf(stderr,"Unable to create file2.txtn");

perror("File2: ");

return -1;

}

//Create a symlink in "A4PART1" to "file2.txt"

ret = symlink("folder2/file2.txt", "./A4PART1/link4");

if(ret != 0){

fprintf(stderr,"Unable to create symlink link4n");

perror("link4: ");

return -1;

}

close(fd1);

close(fd2);

return 0;

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question