Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * TODO: COMPLETE THE MAIN FUNCTION * This program prints valid ( without quotes ) if the input file contains * a valid state
TODO: COMPLETE THE MAIN FUNCTION
This program prints "valid" without quotes if the input file contains
a valid state of a Sudoku puzzle board wrt to rows and columns only.
It prints "invalid" without quotes if the input file is not valid.
Usage: A single CLA that is the name of a file that contains board data.
argc: the number of command line args CLAs
argv: the CLA strings, includes the program name
Returns if able to correctly output valid or invalid.
Exit with a nonzero result if unable to open and read the file given.
int main int argc, char argv
TODO: Check if number of commandline arguments is correct.
Open the file
FILE fp fopenargv r;
if fp NULL
printfCant open file for reading.
;
exit;
will store the board's size, number of rows and columns
int size;
TODO: Call getboardsize to read first line of file as the board size.
TODO: Dynamically allocate a D array for given board size.
You must dyamically create a D array of pointers to other D arrays of ints
Read the remaining lines.
Tokenize each line and store the values in your D array.
char line NULL;
sizet len ;
char token NULL;
for int i ; i size; i
read the line
if getline&line, &len, fp
printfError while reading line i of the file.
i;
exit;
token strtokline DELIM;
for int j ; j size; j
TODO: Complete the line of code below
to initialize elements of your D array.
ADD ARRAY ACCESS CODE HERE atoitoken;
token strtokNULL DELIM;
TODO: Call validboard and print the appropriate
output depending on the function's return value.
TODO: Free dynamically allocated memory.
Step 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