You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example, you can see the use of `argv[0]` to display the program name
261
+
It is a common pattern to check the arguments passed before doing anything else and exit the program if they are incorrect.
262
+
Finally, we can use `argv[1]` as we would any other NTCA.
263
+
We could even access the individual characters of the filename by doing something like `argv[1][0]`.
264
+
265
+
Now, you may be wondering, "how do I get fancy-dancy options parsing, like `ls` and friends?"
266
+
Well, there are a few options.
267
+
The classic choice is [`getopt`](https://www.gnu.org/software/libc/manual/html_node/Getopt.html),
268
+
but the C standard library also has [a few other options](https://www.gnu.org/software/libc/manual/html_node/Parsing-Program-Arguments.html).
269
+
Boost also has a C++-style library for argument parsing, [program_options](http://www.boost.org/doc/libs/1_65_0/doc/html/program_options.html).
270
+
Or, you can write your own!
271
+
177
272
# Submitting homework with Git
178
273
179
274
180
275
[^another]: Windows is also an operating system.
181
276
[^google]: Uh... Google it.
182
277
[^pun]: Pun intended.
278
+
[^2d]: Yep, it's a two-dimensional array. We use `char**` rather than something like `char[][100]` since we don't know how big the array or its subarrays will be;
279
+
the operating system works this out when it runs your program.
0 commit comments