I have this block of code which is meant to output the lines of numbers generated and which should do so in a patter whereby the first line has 300 1s+0s and each subsequent line has ten fewer characters until the final one which has only 10. For some reason when I run it however I get some lines shorter than they should be. Specifically the fourth line generated by this is only 205 characters long instead of the 260 characters it should be. Also line 12 is only 55 characters long. Where is the problem in the code?
Code:
for(bi=1; bi<31; bi++) { b[bi].trait[0]=b[31].trait[bi*10];
b[bi].counter[0]=b[31].counter[bi*10];
for(i=1; i<(310-(bi*10)); i++) {
if(ri>1689) for(i=0; i<2000; i++) {
ran[i]=rand();
ri=0;
}
if(b[bi].trait[i-1]) {
b[bi].trait[i]=gen();
if(!b[bi].trait[i]) b[bi].counter[i+1]++;
}
else {
b[bi].trait[i]=rev(b[bi].counter[i], ii);
if(!b[bi].trait[i]) b[bi].counter[i+1]=b[bi].counter[i]+1;
}
fprintf(fp, "%d", b[bi].trait[i]);
}
fprintf(fp, "\n");
matrix[bi][ii]=b[bi].trait[309-(bi*10)];
}