Use a switch()
~
So basically I want to make a program that uses the -h -l -s and so on things (not to sure what their called, which makes it difficult to google)
E.G.
I've seen a open-source program that does it and I've tried to extract what it uses into my program but it never seems to work. (compiled perfectly fine but crashed when I try to use the arguments)Code:C:\WINDOWS\>example -h
(it used the arguments in main() to "scan" for the letters)
I thought I would ask you guys for a lil but of help.
Use a switch()
~
"If the world hates you, keep in mind that it hated me first." John 15:18
They are called parameters. Heres an example:
If you type in "example -asd -dvdsv -asdsa 1231" in command line the program will outputCode:#include <windows.h> #include <iostream> using namespace std; int main(int argc,char *argv[], char *envp[]){ //number of command line arguments , command line strings for(int i=0;i<argc;i++)cout<<argv[i]<<endl; }
In your main function you have argc and argv. argc is the number of arguments in argv and argv contains these strings. The first string in argv is the file path and the rest are parameters.Code:(folder path)\example.exe -asd -dvdsv -asdsa 1231
There are five possible operations for any army. If you can fight, fight; if you cannot fight, defend; if you cannot defend, flee; if you cannot flee, surrender; if you cannot surrender, die." - Sima Yi