You understand that this loop has no body

while(i!=length && disc!=0);

-maybe irrelevant to the problem :)