I can get the program to work without the pointers but i really wanna use them or i'll never get the hang of them. I seem to get the same problem over and over again:
0064 Error:=Requires an |value operand
0064 Error:=An object of type 'int' cannot b assigned to an object of type 'int'
0066 Error:=Only the integer value zero may b coerced to pointer type
0066 Error:=An object of type 'int' cannot b assigned to an object of type 'int'
0067 Error:=Requires an |value operand
0067 Error:=An object of type 'int' cannot b assigned to an object of type 'int[100]'
Code:
#include <stdio.h>
#include<clib.h>
#include <stdlib.h>
#define MAXCOL 100
#define MAXROW 100
int main(void)
{
FILE *game;
int r,c,total,N,score,x,y;
char repeat;
int matrix[100][100];
if((game=fopen("C:\\Documents and Settings\\lxh346\\Desktop\\ref.txt", "r")) != NULL)
{
printf ("Game of Life rules\n");
for ( r = 0 ; r < 100 ; r++ )
{
for ( c = 0 ; c < 100; c++)
{
{
{
fscanf( game, "%d", &matrix[r][c] );
printf("%d", matrix[r][c]);
}
printf("\n");
}
{
printf ("\nThis is the Original Generation
\n\nPress a Key to create Second Generation\n");
getch(); //Stops programme until user inputs a value//
system("cls"); //Clears Screen//
printf(" Welcome to the Game of Life.\n");
printf ("Updating Matrix\n\n");
{
{
for ( r = 0 ; r < MAXROW ; r++ )
{
for ( c = 0 ; c < MAXCOL; c++)
{
score = 0;
for(x=-1;x<=1;x++)
{
if( (r+x>=0) || (r+x<MAXCOL) )
for(y=-1;y<=1;y++)
if( (c+y>=0) || (c+y<MAXROW))
if(*(matrix + ((c+y)*MAXCOL) + (r+x) ) > 0)
{
score++;
}
}
}
}
}
if(score > 3)
line 64 if(*(matrix+(c*MAXCOL)+r)==0)
*(matrix+(c*MAXCOL)+r)=-1;
else
if(*(matrix + (c*MAXCOL) + r) == 1)
*(matrix + (c*MAXCOL) + r) = 2;
printf(" %d", matrix[r][c]); //prints new matrix values//
}
printf("\n");
}
}
{
game = fopen ( "C:\\Documents and Settings\\lxh346\\Desktop\\ref.txt", "w" );
//open file with write access//
if ( game == NULL )
{
printf ( "File open failure" ); //incase of missing link//
}
}
fprintf ( game, "%d", matrix[r][c]);
//print values back into text file//
fclose (game); //closes file//
printf ("\nDo you want to run it again? Y/N\n"); //option to re-run programme//
repeat=getch();
system ("cls"); //Clears Screen//
}
while (repeat=='y'); //if user types 'y', programme repeats//
}
else printf ("File could not be opened\n");
}