Question
Trying to read in a single array from a file into a 28x28 2d array. What is given (void GetNextImage(ifstream& datastream, int counters[], Record& data))
Trying to read in a single array from a file into a 28x28 2d array.
What is given (void GetNextImage(ifstream& datastream, int counters[], Record& data))
int counters[] used in main program like this ( int counters[10]; // Holds frequency of occurrence of each digit within data file)
Record is a structure with (int digit) and (int image[MAXROWS][MAXCOLS]) in it.
MAXROWS = 28 Global Variable in main program.
MAXCOLS = 28 Global Variable in main program.
LIMIT = 10 Global Variable in main program. This is used in the main program as ( Record r[LIMIT]; // Record for temporary storage of tens lines of data from file )
This function is used in the main program, which draws out a number using a 28x28 2d array. This function reads in a single line of data and puts it in a 2d array so the main program can draw it out. The first line of the input file is what number should be drawn, the rest should go into the 2d array. There are 10 sets in the input file, and each one is a different number it needs to write.
Example:
Input File: 70,0,0,0,0,0,23,44,55,33,30,0,0.....(754 numbers excluding 7) 7 is the number that needs to be written, the rest are to be put in a 28x28 2d array.
2,0,0,0,0,0,0,0,33,45,56,66,0,0.......(754 numbers excluding 2) 2 is the number that needs to be written, the rest are to be put in a 28x28 2d array.
So this function when called needs to pull the (int digit) from the input file, then put the rest of the numbers in a 28x28 array while skipping commas.
3.// Functions 4 void GetNextImage (ifstream& datastream, int counters, Record& data) //came from Record Structure in main.cpp //came from Record Structure in main.cpp int digit; 7 8 9 10 int image [MAXROWS] [MAXCOLS] datastreamdigit: //getting first digit from input file int x 0; 12 13 int y = 0; while (x > image[x] yl //putting numbers from input into a 28x28 matrix 17 18 Y+ti 20 21 if (y 28) y = 0; 23 25 26 27 28 29 //TESTING cout > image[x] yl //putting numbers from input into a 28x28 matrix 17 18 Y+ti 20 21 if (y 28) y = 0; 23 25 26 27 28 29 //TESTING coutStep 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