Answered step by step
Verified Expert Solution
Link Copied!

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)- PA7
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 30 PA7-8
1015
setup() returns RETRN_FAIL 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 fclose(fpbook).
main() I/O 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 0 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 (int)fwrite() and the I/O sizes are small.
Make sure to always fclose(fdbook) regardless of what rdbuf() returns and then return either EXIT_SUCCESS (if all ok) or EXIT_FAILURE otherwise.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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