when u start up a proper dos progra u can can put
/? and /c /d to do different things
Just wondering how u would do this
when u start up a proper dos progra u can can put
/? and /c /d to do different things
Just wondering how u would do this
You mean something like this?Code:int main(int argc, char *argv[]) { for(int i = 1; i < argc; i++) if(argv[i][0] == '/') printf("argument: %s\n", argv[i]+1); return 0; }
i mean like
C:/>format /b
or
C:/>dir /w
Thats what that piece of code do. Try it!
This code will do certain things if you include flags (/b, /w, ...)as parameters when you run the program, ie:
C:/MyFolder/MyProgram /b /w /n /w
Code:int main(int NrOfArguments, char* ArgumentList[]) { if(NrOfArguments > 1) { for(int i=1; i<NrOfArguments; i++) { if(strcmp("/b", ArgumentList[i]) == 0) { //Do something if the flag /b exists ... } else if(strcmp("/w", ArgumentList[i]) == 0) { //Do something if the flag /w exists ... } } } //The rest of your program ... }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
c++ (well duh) help
well DUH, how about you write something a bit more descriptive for a subject title then!?
"command line switches" would have been much better.
U.
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.