Question
Here is what I have so far: void get_ints( char ** argv, unsigned int * input_one, unsigned int * input_two, unsigned long int * output,
Here is what I have so far:
void get_ints(char** argv, unsigned int* input_one, unsigned int* input_two,
unsigned long int* output, int num_ints)
{
int i =0;
FILE* file1 = fopen(argv[1], "r");
FILE* file2 = fopen(argv[2], "r");
if (file1 == NULL || file2 == NULL) {
exit(EXIT_FAILURE);
}
fscanf(file1, "%d ", &input_one[i]);
fscanf(file2, "%d ", &input_two[i]);
fclose(file1);
fclose(file2);
}
Please try to implement this function using fgets() instead of fscanf(). Since the largest number is 4294967295, we need 12 characters (including the null character and new line) to read a number from the file
/* This function reads in num_ints integers from the two input files and stores them in input_one (first input file) and input_two (second input file). If one or both of the files do not exist, it should exit with EXIT_FAILURE. input parameters: char** argv unsigned int* input_one unsigned int* input_two int num_ints return parameters: none */ void get_ints (char** argv, unsigned int* input_one, unsigned int* input_two, unsigned long int* output, int num_ints)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