Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the language, write a program called hwi.c and compile it to generate hwi.o. gcc hw1.c - hwl.o The program should be invoked like this:

image text in transcribed
image text in transcribed
image text in transcribed
Using the language, write a program called hwi.c and compile it to generate hwi.o. gcc hw1.c - hwl.o The program should be invoked like this: ./hwi.o -i input file - output file ./hw1.o - output file - inputfile That is, the-iswitch can appear before the situations) switch or after you should be able to handle both where o input file: path to a text file that contains several sentences (1 sentence per line). For example, the content of input file can be: Ububtu virtual machine Do not forget that arrays begin at zero Remove the null terninator Flve incredible postseason conebacks You can assume that: a) Each line is less than or equal to 511 characters long (512 with the trailing null "10). b) All lines end with a trailing newline 'In output file: path to a file that does not exist. Your program should create this file and populate it with the sentences from input file but with words shown in reverse order. Taking the above as an example, a correct output file should contain the following: machine virtual Ubuntu zero at begin arrays that forget not to terninator null the Remove comebacks postseason incredible Five . If the program is invoked with the wrong number of arguments, you should print to stderr the following and exit: usage: progi.o -i -o coutput_file_path> if the program is invoked with an input file that does not exist, you should print to stderr the following and exit: File inputfile does not exist Using the language, write a program called hw1.c and compile it to generate hw1.o. gcc hw1.c -o hw1.o The program should be invoked like this: ./hw1.o -i input file -o output file or ./hw1.0 -0 output file -i input file That is, the -i switch can appear before the -o switch or after (you should be able to handle both situations) where: o input file: path to a text file that contains several sentences (1 sentence per line). For example, the content of inputfile can be: Ububtu virtual machine Do not forget that arrays begin at zero Remove the null terminator Five incredible postseason comebacks You can assume that: a) Each line is less than or equal to 511 characters long (512 with the trailing null '\0'). b) All lines end with a trailing newline ' ' e: path to a file that does not exist. Your program should create this file and populate it with the sentences from input file but with words shown in reverse order. Taking the above as an example, a correct output file should contain the following: nachine virtual Ubuntu zero at begin arrays that forget not Do terminator null the Remove comebacks postseason incredible Five If the program is invoked with the wrong number of arguments, you should print to stderr the following and exit: usage: progi.o -i - If the program is invoked with an input file that does not exist, you should print to stderr the following and exit: File input file does not exist

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

Students also viewed these Databases questions