From the course: C Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using the main() function's arguments

Using the main() function's arguments - C Tutorial

From the course: C Essential Training

Start my 1-month free trial

Using the main() function's arguments

- No matter how graphical the operating system, internally programs are launched and services started by using a command line. First comes the commands name; this is followed by a series of options or switches, (keyboard clicking) the program processes this information as command line input, it works as you see here because these command line arguments are also the arguments to every C program's main function. This exercise file contains the code for the arguments program run at the command prompt, the main functions arguments are set at line three. Specifying these options is optional if they're not used in the code, but they're always available, also you never specify a void between the parentheses, if you're not going to use the arguments just leave the parentheses blank as you've seen in other C language programs where the main functions arguments are not used. These arguments are traditionally named argc, which is an…

Contents