You still haven't posted the code that causes the errors, and the full text of the error (although in case of MSB3721 this may not be helpful - it is a generic error code).
I can only say that the index you use to assign elements in C are incorrect! You may not believe so since your program outputs the correct result, but this is only the case because you print each cell of C right after it's calculated, using the same incorrect index value, and obviously before there is a chance for it to be overwritten!
That the code can't function can be easily seen: the minimum inde values used for C in this code is 1, for both rows and colums, so the first row and column is never assigned! Furthermore, the largest index values are 2+3+1=6 and 3+2+1=6, so some of the values get written into random memory, causing undefined behaviour.
You can check the actual content of C if you add the following loop to the function KroneckerProduct():
for (int i=0; i < 6; ++i) {
printf("\n");
for (int j=0; j < 6; ++j) {
printf("%d\t", C[i][j]);
}
}
You will get something like this:
-971846352 32519 -343317296 32767 -971795976 32519
64550200 0 6 12 -965645592 32519
0 0 18 24 -965709824 32519
4195187 0 6 0 4195096 0
0 5 7 0 0 0
-343317112 2 3 0 -965708464 32519
The correct product function should be something like this:
for (int i = 0; i < rowa*rowb; ++i) {
int ai = i/rowb;
int bi = i%rowb;
for (int j = 0; j < cola*colb; ++j) {
int aj = j/colb;
int bj = j%colb;
C[i][j] = A[ai][aj]*B[bi][bj];
}
}
This will produce the correct output:
0 5 2 0 10 4
6 7 3 12 14 6
0 15 6 0 20 8
18 21 9 24 28 12
0 5 2 0 0 0
6 7 3 0 0 0