This question may be silly.
C standard:(referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared)
What has the localness
to the main function of the variables argc and argv got to do with changing their names? — I know that their names can be changed — I didn't understand the statement in the standard with respect to the localness of the variables. Please help me.

- 205
- 2
- 7
-
Imagine for a moment you would have to `#include
` and used _global_ external `_Argc` and `_Argv` symbols to access arguments. – KamilCuk May 03 '20 at 12:09
2 Answers
"Localness" means that thing that happen inside the scope of "whatever" don't affect the rest of the world. As far as the names of function parameters go, those names are not exposed to outside of the function. What is exposed (to varying degrees depending on implementation and system standards) are the function signatures (aka prototypes).
The term "localness" is not specific to main
. Every function has a local scope. So does main
. And its parameters of type int
and (char*)[]
are not visibly by name to the outside world.

- 159,371
- 13
- 185
- 298
-
My question was: ```What has the localness to the main function of the variables argc and argv got to do with changing their names?``` Just because they are local to main how does that imply their names can be changed? – Niraj Raut May 03 '20 at 12:23
-
@NirajRaut "What has the localness to the main function of the variables argc and argv got to do with changing their names?" Seems to me that the answer, answers that? Can you clarify what you are confused about? – PiRocks May 03 '20 at 12:52
-
@PiRocks Please explain the answer to me in clear words. I am quite dumb to understand. – Niraj Raut May 03 '20 at 12:55
-
1@NirajRaut The names don't matter to any other code outside of `main`. You can name them whatever you want. The caller to your `main` doesn't care about the names. Other functions you call from `main` don't care about the names of the parameters given to `main`. – Shon May 03 '20 at 13:25
-
@NirajRaut imagine functions being a box with "walls" made from a special kind of a shadow figure screen. Inside this box lying on its floor and attached to its wall are objects of peculiar shapes. The objects inside the box have names written on them with a special in. If you're inside the box you can see the names written on the objects. But from the outside you can only "see" the shadow outlines of the objects attached to the walls, but can't read the names. If you're inside of the box you see the local view. – datenwolf May 03 '20 at 13:28
-
@NirajRaut: If the labels written on the objects inside the box changes, it doesn't change the shape of the shadow figure you can see from the outside. –– In the above "analogy" the shape of the outlines corresponds to the type, and only objects being attached to the walls casting a distinct shadow is analogous to be "parameters" to the box. – datenwolf May 03 '20 at 13:29
What has the localness to the main function of the variables argc and argv got to do with changing their names? — I know that their names can be changed — I didn't understand the statement in the standard with respect to the localness of the variables.
I think you're just overlooking the obvious. The question that the standard is trying to address there is "do I need to use the names argc
and argv
for the parameters of main()
?" I think I've actually seen that question posed here on SO, though I wasn't able to find it in a quick search. You seem to be assuming that of course you can name the parameters whatever you want, on account of them being function parameters. The provision you ask about does nothing but affirm exactly that.
I guess you don't appreciate how someone reading the standard might take away a different impression, and you seem especially to have been thrown by the standard naming main
specifically. This is all wrapped up in the facts that main
is the one and only function that the standard specifies a program (as opposed to the C implementation) must supply, and that the standard designates two specific options for main
's signature from which the programmer must choose. No variation from those is possible if the program is to exhibit strict conformance with the language specification. The provision you ask about just clarifies that using different parameter names does not constitute a meaningful change to the signature for this purpose.

- 160,171
- 8
- 81
- 157
-
1I had answered a similar question a few years back: https://stackoverflow.com/a/36945664/1687119 – dbush May 03 '20 at 15:37