Automatic Storage Duration
Write a program that defines two variables of type
int with
automatic storage duration (placed on the stack) inside the
main function scope.
int main()
{
int x = 123;
int y = 456;
std::cout << "The values with automatic storage durations are: " << x << " and " << y;
}
Output:The values with automatic storage durations are: 123 and 456
We can use the following image to visualize the placement of automatic storage objects called x and y:
An illustration of the memories ...