You still have a number of problems.
1) Where you declare the sum array:
1 2 3
|
int i;
int j;
float sum[i][j];
|
i and j have not been assigned values. They should also be constants, not variables.
I think you want a 20x20 array for sum so
float sum[ARRAY_WIDTH][ARRAY_HEIGHT];
would be better. Actually, you don't need this array at all.
Instead of:
1 2
|
sum[i][j] = stars[i][j] + stars[i+1][j] + stars[i-1][j] + stars[i][j+1] + stars[i][j-1];
if ( (sum[i][j]/5) > 6.0)
|
Why not just:
|
if ( (stars[i][j] + stars[i+1][j] + stars[i-1][j] + stars[i][j+1] + stars[i][j-1])/5 > 6.0)
|
2) The stream operators for file I/O point in the direction that the data is flowing.
When reading from a file the data flows from the file to the place you are going to store it:
inputFile >> stars[i][j];
When writing to the file the data flows from the array to the file:
|
outputFile << " *";// if a star is detected
|
3) Why are you reading from the file to 6x8?
1 2 3 4 5 6 7
|
for(i=0;i<6;i++)// why 6?
{
for(j=0;j<8;j++)// why 8?
{
inputFile >> stars[ARRAY_WIDTH][ARRAY_HEIGHT];// should be stars[i][j]
}
}
|
Your data in the file is 20x20, not 6x8
4) Where you use cout that will send output to the console, not to outputFile. There's no reason to use cout in your program.
I hope this straightens out some of the issues.