I am writing a simple C program to create a twelve tone matrix. The code compiles, but I get run time error 'Bus Error'. In the debugger it says EXC_BAD_ACCESS.
int main ()
{
int j,k,l;
int twelve[13][13];
void mat(int twelve[13][13]);
printf("input original tone row \n");
for(j=0;j<=11;j++)
{
scanf("%2i",&twelve[j][0]);
}
mat(twelve);
for(k=0;k<=11;k++)
{
for(l=0;l<=11;l++)
{
printf("%i ",twelve[l][k]);
}
printf("\n");
}
return 0;
}
void mat(twelve)
int twelve[13][13];
{
int j,k,l;
int temp;
/*inversion*/
for(j=1;j<=11;j++)
{
twelve[0][j] = 12 - twelve[j][0];
}
/*fill in columns*/
/*this sections seems to be what's crashing it */
for(k=1;k<=11;k++)
{
for(l=1;1<=11;l++)
{
temp = twelve[0][k] + twelve[l][0];
if(temp >= 12)
{
twelve[k][l] = temp - 12;
}
else
{
twelve[k][l] = temp;
}
}
}
}