© Mikael Olsson 2019
Mikael OlssonModern C Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4288-9_20

20. Input Handling

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 
When a C program is executed, it can accept arguments that are passed to it from the command line. These command-line arguments are useful for controlling the behavior of the program from outside the code. The arguments are passed to the main function, which is then set to accept two parameters as shown here.
int main(int argc, char* argv[]) {}
The integer argc is the number of arguments passed, and argv is a pointer array to the supplied command-line arguments. The first argument argv[0] is the name of the program, so the argument count in argc begins with 1 when no arguments ...

Get Modern C Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.