Hey guys so disregard everything I have done previosly I have made some serious headway on my program at the cost of my sleep and/or health. haha. So at this point the entire program should run except for I am having a problem with the easiest part. The part I am having trouble with has to go within my original matrix, ma, and determine both the MAX, and MIN values in a single function call. I know I am close but I keep getting a segmentation error. Thanks in advance.
Code:
#include<stdio.h>
int mult(int ma[][6], int m, int mb[][6], int row, int col);
int main()
{
int i =0;
int j = 0;
int multiply;
int ma[4][6];
int mb[4][6];
FILE *infile;
FILE *outfile;
infile = fopen("input_prelab3.txt", "r");
outfile = fopen("output_prelab3.txt", "w");
for (i = 0; i<4; i++)
for (j = 0; j < 6; j++)
fscanf(infile, "%d", &ma[i][j]);/*no address*/
printf("Enter a number to mutiply by:");
scanf("%d", &multiply);
mult(ma, multiply, mb, 4, 6);
for (i = 0; i<4; i++)
{
for (j = 0; j < 6; j++)
fprintf(outfile, "%d ", mb[i][j]);
fprintf(outfile, "\n", mb[i][j]);
}
printf("%d %d", max_min(ma));
fclose(infile);
fclose(outfile);
}
int mult(int ma[][6], int m, int mb[][6], int row, int col)
{
int i = 0;
int j = 0;
for(i =0; i<row; i++)
for(j = 0; j<col; j++)
mb[i][j] = m * ma[i][j];
return 0;
}
int max_min(int ma[][6], int row, int col)
{
int i = 0;
int j = 0;
int MAX = ma[0][0];
int MIN = ma[0][0];
for(i =0; i < row; i++)
for(j = 0; j < col; j++)
{
if (ma[i][j]> MAX)
MAX == ma[i][j];
if (ma[i][j] < MIN)
MIN == ma[i][j];
}
return MAX, MIN;
}