Ok so I rewrote everything thusly:
Code:
#include <stdio.h>
#define nRows 8
#define nCols 7
#define FILENAME "assign8in.txt"
int read2D(int array[][nCols], int numRows, int numCols);
void print2D(int array[][nCols], int numRows, int numCols);
int main()
{
int array[nRows][nCols];
int numRows, numCols;
numRows = nRows;
numCols = nCols;
array[nRows][nCols] = read2D(array, numRows, numCols);
print2D(array, numRows, numCols);
return 0;
}
int read2D(int array[nRows][nCols], int numRows, int numCols)
{
int i, j;
FILE *assign8in;
assign8in = fopen(FILENAME, "r");
if (assign8in == NULL)
printf("Error opening input file.\n");
else
{
for (i=0; i<numRows; i++)
{
for (j=0; j<numCols; j++)
{
fscanf(assign8in, "%d", array[i][j]);
}
}
}
fclose(assign8in);
return array[nRows][nCols];
}
void print2D(int array[nRows][nCols], int numRows, int numCols)
{
int i, j;
for (i=0; i<numRows; i++)
{
for (j=0; j<numCols; j++)
{
printf("%3d ", array[i][j]);
}
printf("\n");
}
}
now instead of just sitting and doing nothing for forever, it begins and immediately
gets "----jGRASP cygwin wedge2: process died on signal 11.".
I made return2D return the array because thats what it said to do in the assignment instructions, I'm not sure why its that way - I figured I would realize that as I got to the rest of the code. I'm using jGRASP and cygwin because thats what we have to use for the class (I've had people tell me its a terrible enviroment and compiler).