Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help with c+ + program in UNIX environment You are to download/build/install a very specific version of the program gawk. Then, using your just

need help with c++ program in UNIX environment

You are to download/build/install a very specific version of the program gawk. Then, using your just installed gawk, you are to write a simple gawk program that will calculate and output the sum of some specific columns in a table that is maintained in a file. Finally, you are to create a C++ program that calls your specific gawk to perform its work. Your C++ program must capture the results of the work (the column sums) and display that info. Then, it must add up all the Colum sums and provide a total sum. You must use a Makefile to compile your program.

- You are to write a gawk program that will parse a file that contains 6 columns of numbers. The gawk program should sum up column 1 and column 4 and return both numbers on a single line (just 2 integers and nothing else). Your gawk program should be stored in a file named gawk.code and the table of numbers should be stored in a file called numbers.txt. You create your own numbers table. See the

Example numbers.txt file and the example gawk output below.

From the shell, you may call gawk with this command (using the gawk you compiled): /gawk f gawk.code numbers.txt

See the man page for gawk to get the details of the f flag (and more)

- You are to write a C++ program that will call your gawk program and collect/display the results of the gawk output. The first call to gawk should pass in the version option. You should print out the results to screen and it should display version 3.1.8. The second call to gawk should call the program stored in gawk.code that operates on the number.txt file. This call will return the 2 integers representing the column sums. From within your C++ program, you are to collect the results of the call and print these integer values to the standard ouput. You are then to add the two numbers together and print out the sum of the two numbers to standard output.

o You will need to use the popen/pclose functions to perform your shell call to gawk and to gather the results back into your C++ program. This is a C interface in Unix so make sure you realize you are not working with C++ objects. See man 3 popen for details (the 3 means section three of the manual).

o For getting numbers out of C-style strings (the results of the gawk command), you might want to use the C++ stringstream type. You will need to google how to do this

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

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

More Books

Students also viewed these Databases questions

Question

Analyze the impact of labor unions on health care.

Answered: 1 week ago

Question

Assess three motivational theories as they apply to health care.

Answered: 1 week ago

Question

Discuss the history of U.S. labor unions.

Answered: 1 week ago