(Solved) : Include Include Include Mainh Define Maxnumlength 11 Void Usage Int Argc Char Argv Argc 4 Q43921846 . . .
#include <stdlib.h>#include <stdio.h>#include “main.h”#define MAX_NUM_LENGTH 11void usage(int argc, char** argv){if(argc < 4) {fprintf(stderr,”usage: %s <input file 1> <input file 2><output file>n”,argv[0]);exit(EXIT_FAILURE);}}
/* This function takes in the two input file names (stored inargv) anddetermines the number of integers in each file.If the two files both have N integers, return N, otherwisereturn -1.If one or both of the files do not exist, it should exit withEXIT_FAILURE.input parameters:char** argvreturn parameters:-1 if the two input files have different number ofintegersN if the two input files both have N integers*/int get_num_ints(char** argv){}
/* This function allocates engough memory to the three arraysto storenum_ints elements each.This function should exit with EXIT_FAILURE if the programfails to allocatethe memory.input parameters:unsigned int* input_oneunsigned int* input_twounsigned long int* outputint num_intsreturn parameters:none*/void allocate_mem(unsigned int** input_one, unsigned int**input_two,unsigned long int** output, int num_ints){}
/* This function reads in num_ints integers from the two inputfiles andstores them in input_one (first input file) and input_two(second inputfile).If one or both of the files do not exist, it should exit withEXIT_FAILURE.input parameters:char** argvunsigned int* input_oneunsigned int* input_twoint num_intsreturn parameters:none*/void get_ints(char** argv, unsigned int* input_one, unsignedint* input_two,unsigned long int* output, int num_ints){}/* This function does an element-wise addition between the twoinput arrays(input_one and input_two) of size num_ints and stores theresult in theoutput array (output).input parameters:unsigned int* intput_oneunsigned int* intput_twounsigned long int* outputint num_intsreturn parameters:none*/void sum_ints(unsigned int* input_one, unsigned int*input_two,unsigned long int* output, int num_ints){}/* This function saves the summed output to an output file,whose name wasspecified with the program execution (i.e., argv[3]).The file should containe one integer value per line, similarlyto how theinput files were stored.input parameters:char** argvunsigned int* intput_oneunsigned int* intput_twounsigned long int* outputint num_intsreturn parameters:none*/void save_output(char** argv, unsigned int* input_one,unsigned int* input_two,unsigned long int* output, int num_ints){}/* This program takes in three text file names as input.The first two files contain N integers (where N >=0 and N<= 1,000,000)whose values range from 0 to 4294967295 (i.e., 32-bit unsignedintegers).The last file is the output file that this program shouldgenerate.For all three files, there should be one integer perline.For each line in the two input files, read in the twointegers, add them, andthen store the sum in the output file.Repeat this process until all integers have been read from theinput files.For example, if the two input files have eight integerseeachinput file 1 input file 2 output file——————————————————–1 2 35 2 78 5 131 12 132 2 410 2 121991 2 199311231245 21235 11252480*/int main(int argc, char** argv){usage(argc, argv);// Check the number of integers in the input filesint num_ints = get_num_ints(argv);if(num_ints == -1) {fprintf(stderr, “ERR: The two input files have different # ofintsn”);exit(EXIT_FAILURE);} else {fprintf(stdout, “The two input files have %d integersn”,num_ints);}unsigned int* input_one = NULL;unsigned int* input_two = NULL;unsigned long int* output = NULL;// Allocate memory to store the integersallocate_mem(&input_one, &input_two, &output,num_ints);// Read the integers from the two input filesget_ints(argv, input_one, input_two, output, num_ints);// Sum up the numberssum_ints(input_one, input_two, output, num_ints);for(int i = 0; i < num_ints; i++) printf(“%ldn”,output[i]);// Store the result in the output filesave_output(argv, input_one, input_two, output,num_ints);free(input_one);free(input_two);free(output);return 0;}
Fill out the five empty functions above, please do not changeany given code, do not add more functions.
Expert Answer
Answer to #include #include #include “main.h”#define MAX_NUM_LENGTH 11void usage(int argc, char** argv){if(argc < 4) {fprintf(stde...
OR