so I have a program that reads a netlist and creates a temporary matrix which has organizes the nets as rows and the nodes as columns.
It then looks at the number of nodes connected to each net by comparing each term to one another in the each row.
The program executes correctly up until usually 3-4 rows before the end of the matrix, then goes into a random loop comparing garbage values that are not contained in the matrix and crashes.
I've been troubleshooting for a while now and tried a few different netlist inputs, varying in size from 49-65 rows and it always works right up until 3-4 rows before the finish, so I am hoping anyone can help identify the issue in the loop
Code:for(i=0;i<=nets-1;i++)
{
fscanf(nlist,"%s %d %s",string,&integer,string+3);
fprintf(olist,"\n%s %d %s",string, integer,string+3);
fscanf(nlist,"%d",&integer);
tmpmatrix[i][0]=integer;
printf("\n%d ",tmpmatrix[i][0]);
fprintf(olist,"%d ",integer);
for(k=1;k <=nodes-1;k++)
{
fscanf(nlist,"%d",&integer);
if (integer != tmpmatrix[i][k-1])
{
tmpmatrix[i][k]=integer;
printf("%d ",tmpmatrix[i][k]);
fprintf(olist,"%d ",integer);
length[i]++;
}
else break;
}
}
fclose(olist);
fclose(nlist);
for(i=0;i<=nets-1;i++)
{
for(j=0;j<=length[i]-1;j++)
{
printf("\n");
for(k=j+1;k<=length[i];k++)
{
if (tmpmatrix[i][j] < tmpmatrix[i][k] && tmpmatrix[i][k] < nodes)
printf("%dchange %d<%d ",i,tmpmatrix[i][j],tmpmatrix[i][k]);
}
}
}
}