Part 1 (C/C++ Programming) You will do here what you did in Assignmentl Part3, w
ID: 3595798 • Letter: P
Question
Part 1 (C/C++ Programming) You will do here what you did in Assignmentl Part3, with various functions (in APUE ch03-ch04) Task #1. Write a C/C++ program to create a few directories as shown below in your current directory (dir1, dir2), a few files (filel in current directory, file10 in dirl, file20 in dir2, and a symbolic-link linkl (to link to file20) You should use one of the following system functions (listed in APUE ch3 and ch4 to do this part. APUE ch3- open, ppenat, creat, open, lseek, read, write APUE ch4 - stat, fstat, fstatat, Istat, access, faccessat, umask, chmod, fchmod, fchmodat, chown, fchown, fchownat, lchown, link, linkat, unlink, unlinkat, remove, rename, renameat, symlink, symlinkat, mkdir, mkdirat, rmdir, chdir, fchdir, getcwd For example, to change current directory, you should use chdir() function to change the directory (APUE 4.23 pages 135-137). You should use creat0 function to create each file. You are going to create the files and directories in depth-first order (and left to right). That is, dirl will be created first, then file10, and so on. You should create linkl (a softlink to file20) after file20 is created. From your current directory dir1 dir2 filel linkl file10 file20 Copy and paste your program listing (assign3partl.c or cpp) here Copy and paste Makefile here Copy and paste the output of the program run. Submit two files for your upload: (1) this word document with your answer and (2) a separate zip file (including each shell script and its log of the run) together with (1). Note: no word document no gradeExplanation / Answer
include <windows.h>
#include <string>
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <dir.h>
#include <unistd.h>
using namespace std;
std::string current_working_directory()
{
char working_directory[MAX_PATH+1] ;
GetCurrentDirectoryA( sizeof(working_directory), working_directory ) ;
return working_directory ;
}
int main(void)
{
int i,j;
for(i=1;i<=2;i++)
{
if (mkdir("working_directorydiri",0777)==-1);
{
cerr<<"Error : "<<strerror(errno)<<endl;
exit(1);
}
else
{
cout << "Please enter j value: ";
cin >> j;
ofstream write ("working_directorydiriilej.txt");
if (write.is_open())
{
write << "This is a new file."<<endl;
write.close();
}
else
cout << "Unable to open file";
}
if (j==20)
int symlink(const char *filej, const char *link1)
}
ofstream write ("working_directoryile1.txt");
if (write.is_open())
{
write << "This is the first file."<<endl;
write.close();
}
else
cout << "Unable to open file";
return 0;
}