Brackets by themselves

Hi, if I have something like this in my code:
1
2
3
4
5
6
7
8
9
10
int main(int argc, char **argv)
{
  int *p;
  {
    int i = 5;
    p = &i;
  }
  *p = 6;
  return 0;
}

will the declared variable i be deallocated after the duration of those brackets? If so, is it just a coincidence that this code doesn't produce a segfault?
Last edited on
will the declared variable i be deallocated after the duration of those brackets? If so, is it just a coincidence that this code doesn't produce a segfault?

Correct, and correct.
Topic archived. No new replies allowed.