These pictures will tell you what has been done in part A, so you can do part b.
ID: 3752177 • Letter: T
Question
These pictures will tell you what has been done in part A, so you can do part b.
*******
part b starts here...
PART B - In cs3377 directory, create a subdirectory (a1part2) and cd to a1part2.
Task #1.
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)
Task #2. Write c/c++ program (a1part2task2.c and its executable named a1part2task2).
Note. This may sound a bit odd first but it will make sense after all (or later).
The program (a1part2task2) will (a) compile a1part2task1.c program (which you have written in Part2 Task#1, to make its executable a1part2task1prog) and (b) then it will run this program (a1part2task1prog).
You may use system("command") in your program. For example, to compile a program (a1part2task1.c), you call in your program: system("gcc a1part1task1.c -o a1part2task1prog"). To run a program (a1part2task1prog) after the compilation, you call in your program: system("./a1part2task1prog").
Copy and paste your program listing (a1part2task2.c program) here
Listing of how to compile this program and its log
Listing of the program run (a1part2task2) here
Listing of Makefile to compile these programs
Submit two files (to be attached for your upload): (1) this word document with your answer and (2) a zip file (including each program (source), its executable, and its log of the run, and Makefile).
Part3 - Use of Find command and Regular Expression.
** Do this part in cs1.utdallas.edu
Create a subdirectory(a1part3) in cs3377 directory
Using the find utility, perform the following tasks (where the directory is "/usr/include").
Try first "ls –R /usr/include | wc"
ls -R | wc
24379 23090 362358
This tells that there are 24379 entries in /usr/include.
ubuntu17.10 [Running) - Oracle VM VirtualBox File Machine View Input Devices Help Activities Terminal Sat 21:14 madhav@madhav-VirtualBox:~/Desktop Trash File Edit View Search Terminal Help madhav@madhav-VirtualBox:- cd Desktop/ madhav@madhav-VirtualBox:~/Desktops ls chegg ftp.txt ssh.txt test.c nadhav@nadhav-VirtualBox-/DesktopS mkdir CS337 test.c chegg ssh.txt ftp.txt 914 PM 49 ENIG 15/09/2018Explanation / Answer
PART2-
TASK1 -- a.c
#include<stdio.h>
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");
}
Compile
gcc a.c -w -o a1part2task1
execute
./a1part2task1
TASK2 b.c
#include<stdio.h>
void main() {
printf("Compilation ");
system("gcc /home/shubham/cs3377/a.c -o /home/shubham/cs3377/a1part2task1");
printf("execute ");
system("./home/shubham/cs3377/a1part2task1");
}
compile
gcc b.c -w -o a1part2task2
./a1part2task2
Makefile --
#vi makefile
install:
gcc b.c -w -o a1part2task2
clean:
rm -rf /home/shubham/cs3377/a1part2/* /home/shubham/cs3377/a1part2task1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.