while(i<256&&buff[i]==' ')i++; VS while(i<256 && buff[i++]==' ');

here we just want to divide a simple string with blank space within it , such as " hello world " .

char buff[256]=" hello  world ";

and we have two general well-programmed source solution : 

soluation 1 : 

while( i < 256 && buff[i++] == ' ' );

we use the above code to skip the head blank space on hello

but it rush to i=2 ! but we just have a single blank space on hello

and here we have a normal solution : 

while( i<256 && buff[i]==' ' )i++;

in this way , we get the first NOT blank i=1;

in face , when we use the first ways , i=0 , it satisfy the loop condition , and i=1;

when i=1 , it can not satisfy the condition , but i will increment itself automatically !!!

be careful !

原文地址:https://www.cnblogs.com/dragen/p/4113035.html