SlideShare a Scribd company logo
Write a C or C++ program to run on a Unix platform. This
program will take three arguments. The first argument will be
the pathname of a directory on the system. The second argument
will be a character string. The third argument is the maximum
number of output lines, N. Your program should display at most
N entries in the directory tree in a text file.
You need to implement three system calls: Open, Read, and
Stat
Details of the system calls are given below. You can also use
man command pages to learn more about these system calls.
1. Open system call: DIR *opendir (const char *dirname)
Opendir system call opens a directory and returns a pointer to a
struct DIR. DIR represents a directory stream, which is an
ordered sequence of all directory entries in a particular
directory.
2. Read system call: struct dirent *readdir (DIR *dirp) Once the
directory has been opened, you can read the directory with
readdir system call. Each time you call readdir system call, it
returns another entry in the directory.
3. Stat system call: int stat (const char *path, struct stat *sb)
Once you have the name of an entry, you can use the stat system
call to get more information about it. stat function takes two
arguments, the first is a path name and second is a pointer to
struct stat, which contains information about the file.
Guidelines and Requirements
1. You can use either C or C++ for this programming
assignment.
2. Your program should run on a UNIX platform
3. Add comments (about the function/variable/class) to your
code as much as possible
4. Zip your project including source file(s) and input text data
files (if any)

More Related Content

Similar to Write a C or C++ program to run on a Unix platform. This program wil.docx

Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
meashi
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
fileop report
fileop reportfileop report
fileop report
Jason Lu
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part ii
Svetlin Nakov
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)
hildenjohannes
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Sudharsan S
 

Similar to Write a C or C++ program to run on a Unix platform. This program wil.docx (20)

40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
App A
App AApp A
App A
 
lec1.docx
lec1.docxlec1.docx
lec1.docx
 
System calls
System callsSystem calls
System calls
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
Linux
LinuxLinux
Linux
 
Chapter 4 Linux Basic Commands
Chapter 4 Linux Basic CommandsChapter 4 Linux Basic Commands
Chapter 4 Linux Basic Commands
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Basics of Unix Adminisration
Basics  of Unix AdminisrationBasics  of Unix Adminisration
Basics of Unix Adminisration
 
fileop report
fileop reportfileop report
fileop report
 
C programming
C programmingC programming
C programming
 
Java 3 Computer Science.pptx
Java 3 Computer Science.pptxJava 3 Computer Science.pptx
Java 3 Computer Science.pptx
 
IO and threads Java
IO and threads JavaIO and threads Java
IO and threads Java
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part ii
 
Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)Introduction to Unix-like systems (Part I-IV)
Introduction to Unix-like systems (Part I-IV)
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Raspberry pi Part 6
Raspberry pi Part 6Raspberry pi Part 6
Raspberry pi Part 6
 
20.Namespaces
20.Namespaces20.Namespaces
20.Namespaces
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 

More from smithhedwards48727

Write a essay about Gender stereotype in adaptation of fairy t.docx
Write a essay about Gender stereotype in adaptation of fairy t.docxWrite a essay about Gender stereotype in adaptation of fairy t.docx
Write a essay about Gender stereotype in adaptation of fairy t.docx
smithhedwards48727
 
Write a critical evaluation of your learning outcome. In your re.docx
Write a critical evaluation of your learning outcome. In your re.docxWrite a critical evaluation of your learning outcome. In your re.docx
Write a critical evaluation of your learning outcome. In your re.docx
smithhedwards48727
 
Write a cover letter explaining what makes you qualified to take c.docx
Write a cover letter explaining what makes you qualified to take c.docxWrite a cover letter explaining what makes you qualified to take c.docx
Write a cover letter explaining what makes you qualified to take c.docx
smithhedwards48727
 

More from smithhedwards48727 (20)

Write a five page paper that analysis the HispanicLatino politics i.docx
Write a five page paper that analysis the HispanicLatino politics i.docxWrite a five page paper that analysis the HispanicLatino politics i.docx
Write a five page paper that analysis the HispanicLatino politics i.docx
 
Write a five (5) paragraph (or longer) essay response . Write your e.docx
Write a five (5) paragraph (or longer) essay response . Write your e.docxWrite a five (5) paragraph (or longer) essay response . Write your e.docx
Write a five (5) paragraph (or longer) essay response . Write your e.docx
 
Write a few words about Email threats briefly and & An.docx
Write a few words about Email threats briefly and & An.docxWrite a few words about Email threats briefly and & An.docx
Write a few words about Email threats briefly and & An.docx
 
Write a essay about Gender stereotype in adaptation of fairy t.docx
Write a essay about Gender stereotype in adaptation of fairy t.docxWrite a essay about Gender stereotype in adaptation of fairy t.docx
Write a essay about Gender stereotype in adaptation of fairy t.docx
 
write a draft of your research paper. in your draft copy, develop th.docx
write a draft of your research paper. in your draft copy, develop th.docxwrite a draft of your research paper. in your draft copy, develop th.docx
write a draft of your research paper. in your draft copy, develop th.docx
 
Write a draft of your Research Paper.In your draft c.docx
Write a draft of your Research Paper.In your draft c.docxWrite a draft of your Research Paper.In your draft c.docx
Write a draft of your Research Paper.In your draft c.docx
 
Write a detailed, analytical paragraph on the short story, incorpora.docx
Write a detailed, analytical paragraph on the short story, incorpora.docxWrite a detailed, analytical paragraph on the short story, incorpora.docx
Write a detailed, analytical paragraph on the short story, incorpora.docx
 
Write a dialogue involving at least 10 - 15 interchanges about the e.docx
Write a dialogue involving at least 10 - 15 interchanges about the e.docxWrite a dialogue involving at least 10 - 15 interchanges about the e.docx
Write a dialogue involving at least 10 - 15 interchanges about the e.docx
 
Write a detailed report on one of the following topics1- Differ.docx
Write a detailed report on one of the following topics1- Differ.docxWrite a detailed report on one of the following topics1- Differ.docx
Write a detailed report on one of the following topics1- Differ.docx
 
Write a detailed report about a residential burglary. You are the of.docx
Write a detailed report about a residential burglary. You are the of.docxWrite a detailed report about a residential burglary. You are the of.docx
Write a detailed report about a residential burglary. You are the of.docx
 
Write a detailed report about a armed robbery to a convenience store.docx
Write a detailed report about a armed robbery to a convenience store.docxWrite a detailed report about a armed robbery to a convenience store.docx
Write a detailed report about a armed robbery to a convenience store.docx
 
Write a detailed report on International Association of classifi.docx
Write a detailed report on International Association of classifi.docxWrite a detailed report on International Association of classifi.docx
Write a detailed report on International Association of classifi.docx
 
Write a detailed report (15 pages excluding references and intro pag.docx
Write a detailed report (15 pages excluding references and intro pag.docxWrite a detailed report (15 pages excluding references and intro pag.docx
Write a detailed report (15 pages excluding references and intro pag.docx
 
Write a detailed evaluation of CWU — why you decided to come here to.docx
Write a detailed evaluation of CWU — why you decided to come here to.docxWrite a detailed evaluation of CWU — why you decided to come here to.docx
Write a detailed evaluation of CWU — why you decided to come here to.docx
 
Write a detail Psychiatric diagnosis and Treatment planregimen .docx
Write a detail Psychiatric diagnosis and Treatment planregimen .docxWrite a detail Psychiatric diagnosis and Treatment planregimen .docx
Write a detail Psychiatric diagnosis and Treatment planregimen .docx
 
Write a description of a process of doing grocery shopping so that y.docx
Write a description of a process of doing grocery shopping so that y.docxWrite a description of a process of doing grocery shopping so that y.docx
Write a description of a process of doing grocery shopping so that y.docx
 
Write a critical evaluation of your learning outcome. In your re.docx
Write a critical evaluation of your learning outcome. In your re.docxWrite a critical evaluation of your learning outcome. In your re.docx
Write a critical evaluation of your learning outcome. In your re.docx
 
write a description of Federich Woehler, Martin Kamen, Cornelis Bern.docx
write a description of Federich Woehler, Martin Kamen, Cornelis Bern.docxwrite a description of Federich Woehler, Martin Kamen, Cornelis Bern.docx
write a description of Federich Woehler, Martin Kamen, Cornelis Bern.docx
 
Write a cover letter explaining what makes you qualified to take c.docx
Write a cover letter explaining what makes you qualified to take c.docxWrite a cover letter explaining what makes you qualified to take c.docx
Write a cover letter explaining what makes you qualified to take c.docx
 
Write a critical essay on one of the following topics related to.docx
Write a critical essay on one of the following topics related to.docxWrite a critical essay on one of the following topics related to.docx
Write a critical essay on one of the following topics related to.docx
 

Recently uploaded

678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

Write a C or C++ program to run on a Unix platform. This program wil.docx

  • 1. Write a C or C++ program to run on a Unix platform. This program will take three arguments. The first argument will be the pathname of a directory on the system. The second argument will be a character string. The third argument is the maximum number of output lines, N. Your program should display at most N entries in the directory tree in a text file. You need to implement three system calls: Open, Read, and Stat Details of the system calls are given below. You can also use man command pages to learn more about these system calls. 1. Open system call: DIR *opendir (const char *dirname) Opendir system call opens a directory and returns a pointer to a struct DIR. DIR represents a directory stream, which is an ordered sequence of all directory entries in a particular directory. 2. Read system call: struct dirent *readdir (DIR *dirp) Once the directory has been opened, you can read the directory with readdir system call. Each time you call readdir system call, it returns another entry in the directory. 3. Stat system call: int stat (const char *path, struct stat *sb) Once you have the name of an entry, you can use the stat system call to get more information about it. stat function takes two arguments, the first is a path name and second is a pointer to struct stat, which contains information about the file. Guidelines and Requirements 1. You can use either C or C++ for this programming assignment.
  • 2. 2. Your program should run on a UNIX platform 3. Add comments (about the function/variable/class) to your code as much as possible 4. Zip your project including source file(s) and input text data files (if any)