Im not really sure where my program has gone wrong and would be thankful for any help provided. It compiles and runs up until the first function is called then crashes however I have tried multiple ways to fix it such as different names, changing the return values, changing the prototype functions and changing the types from floats to int but nothing is working.
Here is the code:
#include <stdio.h>
#define Max 4
#define MAX 6
void main(void)
{
FILE *openfilewrite;
int i=0, j=0;
float open, write, read;
float a=0,b,c;
float arr[Max][MAX], arr1[Max][MAX];
float INITIALIZE(float arrr[Max][MAX] ), MULTIPLY(float arrr[Max][MAX], float p ), OPENFILEWRITES(), OPENFILEREAD(), WRITEARRAY(float arrr[Max][MAX] ), READARRAY();
printf("Please enter the integer value you would like to store\n");
scanf("%f", a);
arr[i][j]=0;
arr[i][j]=INITIALIZE(arr[Max][MAX]);
printf("j");
arr1[i][j]=MULTIPLY(arr[Max][MAX],a);
printf("j");
open=OPENFILEWRITES();
write=WRITEARRAY(arr[Max][MAX]);
read=READARRAY(arr[Max][MAX]);
}
float INITIALIZE(float x[Max][MAX])
{
int i=0, j=0;
for(i=0; i<4; i++)
{
for(j=0; j<6; j++)
{
x[i][j]=(i+j);
}
}
return(x[i][j]);
}
float MULTIPLY(float x[Max][MAX],float a)
{
int i=0, j=0;
for(i=0; i<Max; i++)
{
for(j=0; j<MAX; j++)
{
x[i][j]= a*(i+j);
}
}
return(x[i][j]);
}
float OPENFILEWRITES()
{
FILE *openfilewrite ;
if((openfilewrite = fopen("outfile.nums", "w")) == NULL)
{ /*beginning of the if statement*/
printf("ERROR: file %s can not be opened!\n", "outfile.nums");
exit();
}
return(0);
}
float WRITEARRAY(float x[Max][MAX])
{
FILE *openfilewrite ;
int i=0, j=0;
if((openfilewrite = fopen("outfile.nums", "w")) == NULL)
{ /*beginning of the if statement*/
printf("ERROR: file %s can not be opened!\n", "outfile.nums");
exit();
}
for(i=0; i<Max; i++)
{
for(j=0; j<MAX; j++)
{
fprintf(openfilewrite,"%f\n", x[i][j]);
}
}
return(x[i][j]);
}
float OPENFILEREAD()
{
FILE *openfilewrite ;
if((openfilewrite = fopen("outfile.nums", "r")) == NULL)
{ /*beginning of the if statement*/
printf("ERROR: file %s can not be opened!\n", "outfile.nums");
exit();
}
return(0);
}
float READARRAY(float x[Max][MAX])
{
FILE *openfilewrite ;
int i=0, j=0;
if((openfilewrite = fopen("outfile.nums", "w")) == NULL)
{ /*beginning of the if statement*/
printf("ERROR: file %s can not be opened!\n", "outfile.nums");
exit();
}
for(i=0; i<Max; i++)
{
for(j=0; j<MAX; j++)
{
fscanf(openfilewrite,"%f", x[i][j]);
}
}
return(0);
}