Question: File Handling open a file check if a file opened close a file read from a file with fscanf ( ) write to a file
File Handling open a file check if a file opened close a file read from a file with fscanf write to a file with fprintf The File Handling Benchmark will be like the D Array Benchmark in that you will be given a code template and asked to pick the correct lines of code from a list of correct and incorrect code lines. Here's is a sample program for your reference. So of the code lines are actual code and others are comments stating what the code should be This should not be memorized hence the reason for part of the actual code being comments instead this should be understood so that you can choose the correct lines of code from the quiz and put them into the correct order. int mainvoid& char infilename char outfilename ; FILE IFHNULI; FILE OFH NULI ; Prompt for and store an input file name infilename Use fopen to open the input file with rt and store returned file handle in IFH if the file did not open the file handle is NULI printfInput file did not open...exiting"; exit ; Use fscanf to read a filename from the first line in the file and use fscanf again to read multiple values from the second line of the file close the input file Use fopen to open the output file with wt output file name was read from the first line of the input file outfilename and store returned file handle in OFH if the file did not open the file handle is NULL printfOutput file did not open...exiting"; exit ; Use fprintf to write to the file manipulate the values read from the input file and write the result to the output file Close the output file return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
