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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Reading from a file3m 25s
-
(Locked)
Writing to a file3m 24s
-
(Locked)
Working with raw data2m 53s
-
(Locked)
Using random file access2m 47s
-
(Locked)
Manipulating files2m 57s
-
(Locked)
Exploring the path2m 8s
-
(Locked)
Reading a directory2m 53s
-
(Locked)
Getting file information2m 46s
-
(Locked)
Using command line arguments2m 44s
-
(Locked)
Calling the operating system2m 46s
-
(Locked)
Challenge: Read and store filenames1m 6s
-
(Locked)
Solution: Read and store filenames2m 52s
-
-
-