I'm running a linux... actually an android with Terminal IDE installed(amazing app) and I created this program with command line arguments...
I run it no errors, but I want them to be able to add a -h option
I have the =="-h" part but still no luck any help would be great...
With single char switches like -h it is also quite common to use operator[] and a switch statement, like below, rather than strcmp. (The code is also tweaked so it treats arg counts other than 1 or 2, and also switches other than -h, as an error.)
And note that that, for historic reasons, the standard from of main uses char* argv[] rather than const char* argv[].
Hey vlad I would try your code... but I have to get a copy of string.h, iostream, etc. Does anyone know where I can get this? My compiler didn't build right
There's no such thing as a "2 dimensional string". argv is an array of strings. The first member, argv[0], is the name of the application. Each subsequent member of the array is one word from the command line.
I have to get a copy of string.h, iostream, etc. Does anyone know where I can get this?
They're part of the C++ standard library, and should be supplied with any compiler.
Hey vlad I would try your code... but I have to get a copy of string.h, iostream, etc. Does anyone know where I can get this? My compiler didn't build right
First of all you should decide whether you will write the program in C or C++. If the program will be written in C you need to include header <string.h>. If the program will be written in C++ you need to include header <cstring>. These headers are part of the standard libraries of the compiler. So it will be simply enough to specify them in your program.