Your struct matrix1 and struct matrix2 confuse me please explain why they appear to be the same thing yet you have two of them? You never seem to have an output for your answer so how do you know anything is wrong (There is something wrong by the way)? Really think about line 67, this seems to be your issue.