cloopsstatic

Static variable in a loop vs variable and a loop in a block


In C we can use blocks to restrict the scope of a variable, so is

{
    int var = /* initialization */;

    while(...) {
        // some stuff with var
    }
}

equivalent to

while(...) {
    static int var = /* initialization */;
    // some stuff with var
}

?


Solution

  • No.