Because you are declaring an int inside the condition:


for(int i=0; i<BUFFERSIZE; i++)

which is more or less pointless, but it is allowed under c99.

Declare i with everything else then...