Answered step by step
Verified Expert Solution
Question
1 Approved Answer
uhhhCmain.c Notes ( C version: see Cmain.c ) - PA 7 This is a relatively short function. Follow the instructions in the starter code. main
uhhhCmain.c Notes C version: see Cmain.c PA
This is a relatively short function. Follow the instructions in the starter code. main calls setup to parse the command line arguments, open the bookfile and set the func pointer to point at either ecrypt or dcrypt Be aware that when calling setup there are two output parameters you are passing addresses of main stack variables to the function setup to change.
CSE PA
setup returns RETRNFAIL if there is an error. Important: If setup fails, then both output variables, fpbook and func, are set to contain NULL. So you do not fclosefpbook
main IO loop consists of the following three steps:
call rdbuf to fill the inbuf from stdin and bookbuf from bookfp with the same number of characters. If is returned EOF was reached on stdin.
Call the function pointed at by func to encrypt or decrypt inbuf.
Call fwrite to write inbuf to stdout. You should cast the return value of fwrite to an int to suppress compiler warnings intfwrite and the IO sizes are small.
Make sure to always fclosefdbook regardless of what rdbuf returns and then return either EXITSUCCESS if all ok or EXITFAILURE otherwise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started