循环中的指针递增,解除引用和比较

Aka*_*ash 2 c

难道这两个意思不一样,首先得到价值再增加?

for ( ; *s == *t; s++, t++)

for ( ; *s++ == *t++;)
Run Code Online (Sandbox Code Playgroud)

ken*_*ytm 6

如果for循环具有引用s和的内容,则为否t.第一个循环可以重写为

while (true)
{
   bool are_equal = *s == *t;
   if (!are_equal) break;

   // Perform stuff inside the for loop
   // Note that 's' and 't' are not increased yet in here.

   ++ s;
   ++ t;
}
Run Code Online (Sandbox Code Playgroud)

第二个循环可以重写为

while (true)
{
   bool are_equal = *s == *t;
   ++ s;
   ++ t;
   if (!are_equal) break;

   // Perform stuff inside the for loop
   // Note that 's' and 't' have been increased in here.
}
Run Code Online (Sandbox Code Playgroud)