Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Part 1 Traverse the directory structure from current directory (recursively, that is, to traverse left-to-right depth-first manner) and (1) to print the current path (with

Part 1image text in transcribed

Traverse the directory structure from current directory (recursively, that is, to traverse left-to-right depth-first manner) and (1) to print the current path (with pwd command using system("pwd") call) and (2) to print any file/directory entries (with ls command, using system("ls") call). Your program should print the result of each pwd from current-directory path name, then to the path name of dir1, and then dir4 and so on.

Reference: https://www.gnu.org/software/libc/manual/html_node/Running-a-Command.html

http://man7.org/linux/man-pages/man3/system.3.html

/* for example, in your program, to run time command */

#include

int main(void)

{

int rc;

rc = system("pwd");

exit(0);

}

/* Example2. to create a file using touch command */

#include

int main(void)

{

int result;

result = system("touch newfile");

}

13 diri dir4. file4 dir2 dirs linki From your current directory dir3 file3 file1 file2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students explore these related Databases questions