s out edu 7 f ca: findAverage (Int int): 8 t find Max (int int): 9 int findMin (
ID: 3821413 • Letter: S
Question
s out edu 7 f ca: findAverage (Int int): 8 t find Max (int int): 9 int findMin (int int) 10 int write Data (char int int) ll int main (int argc, char argv) 12 H 13 int arr int 15 arr (int )malloc (size sizeof (int)) 16 ir (lo Numbers (argv[1], arr, size) 0) 17 18 printf ("error"): 19 20 print Numbers (arr, size): 21 if (write Data (argv[2] arr, size) 1) 22 23 printf ("output written in output.txt' file"); 24 it (argc 2) 25 printt( invalid number of armuments passed. In 26 27 28 return o 300 int loadNumbers (char filename, int arr, int size) 31 t FILE. file tope (filename, "r") 33 if (file NULL) return 0; 35 36 while (!feof (file)) 38 int num: 39 fscanf (file, "id". 40 printf ("id", num) 41 43 if (count size) 46 47 return 49 void printNumbers (int arr, int size) O Type here to search o e a
Explanation / Answer
You doesn't seems to be using argc and argv properly.
argc by default is 1 when nothing is provided and first elemenet of argv (oth index) contains name of the program.
your example shows that you want to have argv[1] as a number, number of numbers
argv[2] is first input file
argv[3] is second input file
argv[4] is first output file
argv[5] is second output file
so your argc should be 6.
I can not help much here as your question is not complete.
So here are pointers to fix your code.
When running your code pass appropriate argument from command line.
check for correct argc and argv value
check argc before using argv to avoid seg faults.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.