[Solved] Checking an identity matrix in C

[ad_1] There are several errors. For example you use variable n before its initialization matrix=(int**)malloc(n*sizeof(int*)); scanf(“%d”,&n); There must be scanf(“%d”,&n); matrix=(int**)malloc(n*sizeof(int*)); You never set variable flag to 1. So it always has value equal to 0 independing of the matrix values. The break statement in this loop for(j=0;j<n;j++) { if(matrix[i][j]!=1 && matrix[j][i]!=0) flag=0; break; } … Read more

[Solved] Prevent duplicate user from being added to database

[ad_1] To preserve the integrity of your database you should add a unique constraint to this column in your database and then catch the exception of the violation of this constraint when performing the UPDATE/INSERT query. [ad_2] solved Prevent duplicate user from being added to database