about the first version of the code you post 'Unregistered'
change the text condition on the line 16
Code:
14 {
15 count+=1;
16 if ((count % N) == 1)
*p = 1;
else
*p = 0;
}
here is tested for 'one' becouse you increment 'count' variable BEFORE the test and also add brackets - '{' and '}' around the statement where you try to assing 1 to elements of the main diagonal of the matrix so it will be executed within the for statement :-)
so when count is divided to N without a reminder set the item to 1
otherwise initialize i with zero.
when you dump the identity matrix, just use the same tehnique -
test the same condition and output an optional '/n'