0

What are the differences between adding and not adding the static keyword in the following array of pointers declaration.

static char *list[MAX] = {
        "Katrina",
        "Nigel",
        "Alistair",
        "Francesca",
        "Gustav"
    };

this declaration is located inside the main function

2 Answers 2

1

With static the array of pointers will have static storage duration and without it will have automatic storage duration. In both cases the string literals pointed by the pointer elements of the array will have static storage duration.

Sign up to request clarification or add additional context in comments.

Comments

0

Given that list is declared in the main function, it will be allocated on the stack unless the static keyword is used. In either case, the string literals will not be allocated on the stack.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.