From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

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

Using command line arguments

Using command line arguments - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Using command line arguments

- [Instructor] The main() function has two arguments: an integer representing the number of strings typed to the command prompter specified to launch the program in a GUI operating system and a character pointer array representing each string typed in the command prompt. The main() function's arguments are required only when you plan on using them. Otherwise you can leave the main() function's parentheses blank. Here you see the arguments specified for the main() function in this exercise file. I've used the traditional names argc for the argument count and argv for argument values. The pointer notation indicates an array of strings. The argument count is always at least one, which represents the program name for the command used to launch the program. This name is the first string in the array, element zero as specified in the printf statement at the end of line five. Bill and run. You see the program name as set by the linker unless some other name was chosen. This exercise file…

Contents