Variable scope behavior c language

Code snippet:

void function(void)
{
    while(1)
    {
         int i = 0;
         i += 1;
         if(i == 500) break;
    }
}

The variable i is stored in stack every time when restart the loop ?
What is the memory structure when running this code ?
What is the behavior of this variable ?
It is a bad or good practice do this ?

Thanks.


Source: c#

Leave a Reply