You are not supposed to make any assumptions about amount of memory allocated to store strings pointed by argv[i]
. In particular, you are not allowed to assume that you can expand these strings by strcat
-ing anything to them. Doing so will generally lead to undefined behavior. This is exactly what you observed in your experiment.
While it is legal to modify the strings pointed by argv[i]
without changing their length, it is not generally possible to "expand" them in place. It is conceivable that these strings might immediately follow each other in memory, meaning that writing anything past the end of string pointed by argv[1]
would overwrite string pointed by argv[2]
and so on.