// Requires: The maximum size of array a is n && n > 0 // Modifies: The array a
ID: 3640413 • Letter: #
Question
// Requires: The maximum size of array a is n && n > 0// Modifies: The array a and n
// Effects: Asks for name of a file to read data from
// Opens the file
// Reads data and enters valid data into the array
//
// You may assume that the number of data items in the file <= n
//
// If all goes well, sets n to hold the number of values read
// and returns true
//
// If anything goes wrong, returns false. It is okay to set n and
// the elements of array a to arbitrary values in that case.
//
// Prompt: "Enter the name of file: "
// "File didn't open"
// "Too many values in file"
// "Wrong datatype in file"
bool loadArrayFromFile(int a[], int &n);
and
// Requires: The maximum size of array a is SIZE x SIZE && SIZE > 0
// Modifies: The array a and n
// Effects: Asks for name of a file to read data from
// Opens the file
// The first number in the file (say, k) will be the number of rows
// and number of columns
// The rest of the file contains the data
//
// You may assume that the rest of the file contains k*k data items
// You may also assume that k <= SIZE
//
// The function reads the data and enters valid data into the array
//
// If all goes well, sets n to k (that is, the number of rows & cols)
// and returns true
//
// If anything goes wrong, returns false. It is okay to set n and
// the elements of array a to arbitrary values in that case.
//
// Prompt: "Enter the name of file: "
// "File didn't open"
// "Wrong datatype in file"
bool loadArrayFromFile(int a[][SIZE], int &n);
Explanation / Answer
If this helps please rate, if not, sorry http://answers.yahoo.com/question/index?qid=20120312193532AA9iUey http://stackoverflow.com/questions/9676580/io-file-code-is-being-inconsistent
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.