I am rather new to programming, and I am trying to write a console program that will create 12 tone matrices.
The code compiles, but when run I get a "bus error".
The debugger says EXC_BAD_ACCESS.
The code compiles, but when run I get a "bus error".
The debugger says EXC_BAD_ACCESS.
Code:
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;}
}}
}