int main can receive command-line arguments through argc and argv. Each argument is supplied as text when the program starts, then interpreted by the program according to its needs. section 7.2
int main(void);
int main(int argc, char* argv[argc+1]);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":0,\"ch\":9},{\"line\":0,\"ch\":13}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":1,\"ch\":19},{\"line\":1,\"ch\":23}]]"}
!@%STYLE%@!
The two common main prototypes contrast a program with no parameters and one receiving argc plus argv. section 7.2
TAKEAWAY
- All command-line arguments are transferred as strings; the program must interpret those strings itself. section 7.2
- argv[0] usually contains the name used to invoke the program, commonly its executable name. section 7.2
- argv[argc] is 0, providing a terminating value beyond the actual command-line arguments. section 7.2
Converting an argument
A program that expects numeric input can treat an argv element as a string and use strtod to decode it as a double. The conversion is a program decision, not an automatic property of the command line. section 7.2
Do not confuse command-line arguments with the arguments in a C function call. Function-call arguments pass values to the called function; command-line arguments arrive through main as strings. section 2.4.2 section 7.2













