Question: below is the question with the code but it is giving me an error when i run it. please show detailed steps. Write a C/C++

below is the question with the code but it is giving me an error when i run it. please show detailed steps.

Write a C/C++ program (a1part2task1.c, and its executable named a1part2task1) to create a few directories and files as you have done in Part1. Your executable is named "a1part2task1".

You may use system("command" ) function call to run "command". For detail, check APUE 8.13 (pages 264-269). To change directory, you may use chdir( ) function call along with getcwd( ) function call. For detail, check APUE 4.23 (pages 135-137, and a sample program in Figure 4.24). Also you may use the sample code as a base for your work (available at the end of this document).

Copy and paste your program listing (a1part2task1.c) here

Copy and paste the log of how to compile this program

Copy and paste the run of your program here (./a1part2task1)

here is the program....

#include void main() { int check; char dir1[100]={0},dir2[100]={0},dir11[100]={0}; printf("Working dir is /home/shubham/cs3377/a1part2 "); strcpy(dir1,"/home/shubham/cs3377/a1part2/dir1"); check = mkdir(dir1); if (check) { printf("Unable to create directory "); exit(1); } printf("Created /home/shubham/cs3377/a1part2/dir1 "); strcpy(dir2,"/home/shubham/cs3377/a1part2/dir2"); check = mkdir(dir2); if (check) { printf("Unable to create directory "); exit(1); } printf("Created /home/shubham/cs3377/a1part2/dir2 "); system("touch /home/shubham/cs3377/a1part2/file3"); printf("Created /home/shubham/cs3377/a1part2/file3 "); strcpy(dir11,"/home/shubham/cs3377/a1part2/dir1/dir11"); check = mkdir(dir11); if (check) { printf("Unable to create directory "); exit(1); } printf("Created /home/shubham/cs3377/a1part2/dir1/dir11 "); system("touch /home/shubham/cs3377/a1part2/dir1/file1"); printf("Created /home/shubham/cs3377/a1part2/dir1/file1 "); system("touch /home/shubham/cs3377/a1part2/dir1/dir11/file11"); printf("Created /home/shubham/cs3377/a1part2/dir1/dir11/file11"); system("touch /home/shubham/cs3377/a1part2/dir2/file2"); printf("Created /home/shubham/cs3377/a1part2/dir2/file2");

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!