for (int i=0;i<=10;i++)
int s=0;
-------------
More standardized writing
int i = 0;
int s = 0;
for(i = 0;i <= 10;i++)
{
s = 0
}
i and s are local variables that apply for address space in the stack. The for loop is just a value-added operation and no space is released.
This is a non-standard way of writing. The C language does not support applying for space at any time. It is estimated that the compilation will not pass.
Will be released. The lifetime of a local variable starts at the declaration and ends at the end of its scope. Change the program to
for(int i=0;i<=10;i++)
{
if(i==0) int s=1;
else s++;
}
Just see it.
#include <cstdio>
int main()
{
for (int i = 0; i <10; i++)
{
int s = 0;
s++;
printf("%d", s);
}
}
The result is 111111, indicating that it has been released