100%(1)1 out of 1 people found this document helpful
This preview shows page 1 - 4 out of 6 pages.
Objectives: reading from sequential access files with proper use of priming read, loop read, and test for end-of-file; one-dimensional arrays, defining functions. In this program you will be writing two functions which you will compile and link with a test driver provided by your instructor. A short main() program is provided below if you would like to unit test your functions before linking with the test driver. The first function, readData(char const *, double , int) accepts as arguments an input file name, a one-dimensional array of double, and an int to indicate the maximum number of tripletsto read from the file into the array. For example, you will probably read values from the file three at a time. The first value will be loaded into the first element, the second value the second element, etc. Continue loading values in groups ofthree from the file into the array, but do NOT load values intothe array if you are unable read a complete set from the file. So, you will need to be testing for End-Of-File, as well as input failure after each individual value is read in (Note: assume all test input files will contain one blank line at the end). Ultimately, the function must calculate and return an intcode as follows: Return Code Message 0x0100 Error: Input file does not exist 0x0200 Input file exists, but contains 0 complete triplets 0x0400 Input file has less than MAX triplets 0x0800 Input file has exactly MAX triplets 0x1000 Input file has more than MAX triplets 0x2000 Error: incomplete number triplet; EOF reached in middle of triplet 0x4000 Error: A value was attempted to be read in, but input
failed 0x8000 Error: Input value not within proper range.