Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All you have to do is read then fill in the blanks in the code. Thumbs up for correct answer! Task 1: Printing File Names

All you have to do is read then fill in the blanks in the code. Thumbs up for correct answer!
image text in transcribed
image text in transcribed
Task 1: Printing File Names using Dirent Library: (50points) Here we want to access a Linux directory using C. To do so we use the structs and functions made available in the dirent library. Below we see the function prototypes for the functions opendir, readdir, and closedir which have been implemented in the dirent library. DIR is simple type that is available from the library SYNOPSIS #include DIR *opendir ( const char *dirname ); struct dirent *readdir (DIR *dir); int closedir (DIR *dir); Dirent structure is defined as follows struct direntf ino t d ino ; /*file serial number*/ off td offoffset to the next dirent unsigned short d reclen ; /* length of this record */ unsigned char d_ type ; /* type of file */ char d_name [ 256 ] ; /*filename The following program displays the filenames contained in a directory whose pathname is passed as a command-line argument. Type in and complete the following program on the computer. Save it as shownames.c. . Compile the program as shownames.out and execute it by giving it a directory as a command ine argument. Fo example type the following nto the terminal: . /shownames.out ~/CSC4421. If you typed that then the program below will receive values of: argc-2, argv[0]"/shownames.out", argv[1]-"-/CSC4421". shownames.c

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

Step: 3

blur-text-image

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

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

Students also viewed these Databases questions

Question

Calcule la molaridad de 32,4 mg de NaCl en una solucin de 122,4 ml

Answered: 1 week ago