Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE SYSTEM CALLS ONLY!!!!!!!!!!! I WILL DEFI ETLY GIVE AN HEADS UP IF YOU SOLVE ALL THE TASKS 1. Measure the time to execute

PLEASE USE SYSTEM CALLS ONLY!!!!!!!!!!! I WILL DEFI ETLY GIVE AN HEADS UP IF YOU SOLVE ALL THE TASKS image text in transcribed

1. Measure the time to execute the 4 sample programs (Sample1,2,3,4.c) Measure the time it takes to print a 10000-character string: - using "write()" to write to the screen, one character at a time. - using "write()" to write to the screen, all 10000 characters at once. - using "printf()" to print to the screen, one character at a time. - using "printf()" to print to the screen, all 10000 characters at once. 2. Reverse a file and write its data either to the screen or to another file (lastnameRV.c): Write a C program (call it lastnameRV) that will reverse the content of a file and prints either to the screen or into a file ( -f flag). The command: Takes either one or two file names (source file sFile, and destination file dFile) as input Takes the following flag combinations: -f: if the dFile exists, its content is overwritten with the reversed content of sFile The commands below show the results given the following files: file contains: "This is the content of file 1." $lastnameRV filel .1 elif fo tnetnoc eht si siht. Will be displayed on the screen. $lastnameRv -f filel file2 file2 content will be: .1 elif fo tnetnoc eht si siht. Other input combinations should give the user hint messages of how to use the command. [ - ] reverse -f [ - ] reverse 3. Print lines containing a matching substring (lastnameGREP.c) Write a C program that takes a string and a file as arguments. This program should print out all lines of the file containing the given string. You can assume the string will not contain any special characters or regular expression syntax. Hint: As with the HEAD problem from last week, you should read the text line-by-line. However, you should only print a line if it contains the search term. If this program does not receive the correct number of arguments, or if it fails to open the given file, it should return errors. ./ carberryGREP obligations apache.txt or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only $ ./carberryGREP Appalachia apache.txt $ ./carberryGREP Usage: ./carberryGREP term file $ ./carberryGREP word notfile Error opening file Expected behavior of your GREP 1. Measure the time to execute the 4 sample programs (Sample1,2,3,4.c) Measure the time it takes to print a 10000-character string: - using "write()" to write to the screen, one character at a time. - using "write()" to write to the screen, all 10000 characters at once. - using "printf()" to print to the screen, one character at a time. - using "printf()" to print to the screen, all 10000 characters at once. 2. Reverse a file and write its data either to the screen or to another file (lastnameRV.c): Write a C program (call it lastnameRV) that will reverse the content of a file and prints either to the screen or into a file ( -f flag). The command: Takes either one or two file names (source file sFile, and destination file dFile) as input Takes the following flag combinations: -f: if the dFile exists, its content is overwritten with the reversed content of sFile The commands below show the results given the following files: file contains: "This is the content of file 1." $lastnameRV filel .1 elif fo tnetnoc eht si siht. Will be displayed on the screen. $lastnameRv -f filel file2 file2 content will be: .1 elif fo tnetnoc eht si siht. Other input combinations should give the user hint messages of how to use the command. [ - ] reverse -f [ - ] reverse 3. Print lines containing a matching substring (lastnameGREP.c) Write a C program that takes a string and a file as arguments. This program should print out all lines of the file containing the given string. You can assume the string will not contain any special characters or regular expression syntax. Hint: As with the HEAD problem from last week, you should read the text line-by-line. However, you should only print a line if it contains the search term. If this program does not receive the correct number of arguments, or if it fails to open the given file, it should return errors. ./ carberryGREP obligations apache.txt or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only $ ./carberryGREP Appalachia apache.txt $ ./carberryGREP Usage: ./carberryGREP term file $ ./carberryGREP word notfile Error opening file Expected behavior of your GREP

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_2

Step: 3

blur-text-image_3

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions