EDIT: Thanks to Mathias Frits Rørvik I was able to figure it out, just make another matrix 2x2 bigger and add the 0's I will not delete what I posted below(it was before I read the above post but I was unable to edit it due to the fact that a mod had to approve it before it was posted), maby someone wants to solve it too or something

I now see I have done a big mistake not telling you all the details, basicly i'm working on this problem and I have gotten to that point that I have to add an outer layer to the matrix, but I do need to work on a matrix, anyways ill just post the problem so I wont fail with the description again

So I read the matrix and in order to solve it they way I am thinking I need to add 0-s around the matrix and do something like:

//I got the mat and r-rows c-columns

int counter=0;

int maxtime=0;

int r=5;

int c=6;

for (i=1; i<r-1; i++){

for(j=1;j<c-1;j++){

if(mat

*[j]!=o){*

counter=counter+9;

//a lot of if's to test for other candles around the candle (and in order to test the outer matrix i need first to concatenate around it 0's

if (mat[i-1][j-1]!=0){

counter=counter-1;}

if (mat [.i][j-1]!=0){

counter=counter-1;}

if (mat[i+1][j-1]!=0){

counter=counter-1;}

if (mat[i-1][j]!=0){

counter=counter-1;}

if (mat[i+1][j]!=0){

counter=counter-1;}

if (mat[i-1][j+1]!=0){

counter=counter-1;}

if (mat[.i][j+1]!=0){

counter=counter-1;}

if (mat[i+1][j+1]!=0){

counter=counter-1;}

If(counter>maxtime){

maxtime=counter;}

}

}

}

printf("%d",maxtime);