Question: Write a C program myls whose behavior resembles that of the system command ls. myls must print the names of files in the current directory

Write a C program myls whose behavior resembles that of the system command ls. myls must print the names of files in the current directory in columns of equal width. myls must accept the following parameters:

$ myls [-rs]

-s switch sorts the filenames in alphabetical order. The file names must be arranged in sequence so that the names in column 1 are followed by the names in column 2, and so on. -r switch sorts the filenames in the reverse alphabetical order.

When no switches are present, myls does not need to sort the file names. Consider using the qsort() library function that implements the quicksort algorithm to sort an array.

$ ls dirA file2.txt file5.txt file8.txt file0.txt file3.txt file6.txt file9.txt file1.txt file4.txt file7.txt

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!