Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C , Write a utility program that takes one or two arguments (filename and -n) and writes to STDOUT the first n lines of

IN C,

Write a utility program that takes one or two arguments (filename and -n) and writes to STDOUT the first n lines of the file filename. If filename is not specified, the program should read from STDIN If -n is not specified, the program should write only the first line. Your program should read the file 10 characters at a time.

Your should only use system calls for obtaining input and generating output. For example, use read() and write() system calls instead of C library functions (e.g. scanf or printf) to fetch input and display output.

image text in transcribed

image text in transcribed

1 abc 2 def ghi 3 jkl mno 4 par stu vwx 5 yz -/Documents/test> ./header abc abc def ghi jkl mno par stu vwx yz ABC DEF GHI JKL MNO POR STU VWX YZ -/Documents/test> ./header abc - 10 abc def ghi jklmno par stu vwx yz ABC | DEF GHI JKL MNO POR STU VWX 6 ABC 7 DEF GHI 8 JKL MNO 9 PQR STU VWX 10 YZ 11 12 123 456 6790 13 For initial testing, I set the default number of lines to print to 10. In the final version, the number should be 1. YZ - Documents/test> --/Documents/test> ./header abc - 1 abc - Documents/test> ./header abc -2 abc def ghi - Documents/test> ./header abc - 3 abc def ghi jkl mno - Documents/test> ./header abc - 5 abc def ghi jkl mno par stu vwx yz -/Documents/test> ./header abc -11 abc def ghi jkl mno par stu vwx yz ABC DEF GHI JKL MNO POR STU VWX YZ - Documents/test>

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

What are the attributes that make a founder of a firm successful?

Answered: 1 week ago