From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Using the main() function's arguments

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

From the course: Complete Guide to C Programming Foundations

Using the main() function's arguments

- [Instructor] No matter how graphical the operating system, internally, programs are launched and services started by using a command line. First comes the command name. This is followed by options, switches or other information. (keys tapping) The program obtains these command line arguments from the main function where they become the main function's arguments. This exercise file contains the code for the arguments program I just ran the command prompt. The main functions arguments are specified at line 3. If you don't use the arguments, you can leave the parentheses blank, definitely don't put void in there. The first argument is an integer. The argument count or number of items available on the command line. Traditionally it's named argc. The second argument contains the strings or text typed at the command prompt. Each item separated by a space or tab is its own string. You see the string here was enclosed in double quotes, so it becomes a single item. The traditional name for…

Contents