jeudi 30 avril 2020

C - Variable Declaration in If Condition Available in Else?

If I declare a variable in an if condition in C, is that variable also available to the else branch? For example:

if((int x = 0)){
  foo();
} else{
  x++;
  bar(x);
}

Couldn't find the answer, at least not the way that I worded it. Please help.

Aucun commentaire:

Enregistrer un commentaire