Initialization vs Assignment in C

In the C Standard, only option (1) is initialization.

In programming jargon, both may be considered initialization. Your question is really asking about the meanings of words.

It’s normal for people to use words with various common meanings, instead of switching terminology for particular languages. Another example is “pass by reference”. Does C have pass by reference or not? Some would argue it only has pass by value, others would argue that passing by pointer implements the concept of “pass by reference”.

Then we could talk about deep copy vs shallow copy (which is not mentioned by the C Standard at all), or the terms “stack” and “heap” (which are not mentioned by the C Standard either, but commonly used by C programmers), and so on.

If you say { int b; b = 5; } isn’t initialization (because the C Standard says it isn’t) then, to be consistent, you should also say that b is not a stack variable.

Leave a Comment