Code:
/*
* Programmer: Jeff Clay
* Class: GME 61
* Date: 8-7-12
* Program: READING IN ARRAYS
*
* Purpose: READ IN ARRAYS, COMPUTE AVERAGE
*
*/
#include <stdio.h>
#include <stdlib.h>
#define maxRow 2
#define maxCol 3
#define _CRT_SECURE_NO_WARNINGS
void printMatrix(double array[maxRow][maxCol], int row, int column);
void add_matrices(double xArray[maxRow][maxCol], double yArray[maxRow][maxCol], double zArray[maxRow][maxCol], int row, int column);
main()
{
double xArray[1][3], yArray[1][3], zArray[1][3];
char fileName[256];
int i,j;
FILE *fileIn, *fileOut;
i=0;
j=0;
printf("Enter input file path:\n");
gets(fileName);
fileIn=fopen(fileName, "r");
if (fileName==NULL)
{
printf("Filepath DNE");
exit(-1);
}
/*printf("Enter output file path:\n");
gets(fileName);
fileOut=fopen(fileName, "w");
if (fileName==NULL)
{
printf("Filepath DNE");
exit(-1);
}*/
while(fscanf_s(fileIn,"%lf", &xArray[3][1])!=EOF)
/*add_matrices(xArray,yArray,zArray,3,1);*/
{
printMatrix(xArray,3,1);
/*printf("+ \n");*/
}
/*double a[2][3]={{1.0, 2.0, 3.5},{4.0, 5.0, 6.0}};
double b[2][3]={{-6.0, -5.0, -4.0},{ -3.0, -2.1, -1.5}};
double c[2][3];
add_matrices(a,b,c,3,2);
{
printMatrix(a,3,2);
printf("+ \n");
printMatrix(b,3,2);
printf("= \n");
printMatrix(c,3,2);
}*/
}
void printMatrix(double array[maxRow][maxCol], int row, int column)
{
int i, j;
for (i=0; i<column; i++)
{
for (j=0; j<row; j++)
printf("%.2lf\t", array[i][j]);
printf("\n");
}
}