Question:
question about command line arguments?
ItachisXeyes
2009-08-28 10:26:32 UTC
what is the difference between "-" and "/" in the command line (windows)
whenever your looking at the arguments you can put on say "shutdown" they give examples with a - to separate the argument but the arguments for chkdsk are defined by a /

what is the difference to the command line? and why are there two different symbols to show an argument?
Three answers:
▐▀▀♦▀▀▌ ♦Oprah♦ ▐▄▄♦▄▄▌
2009-08-28 10:58:51 UTC
Just a convention.



Every program is free to define its own argument format; if the developers wanted, they could've easily written chkdsk to use something totally original like "chkdsk ~~A ~~B"



But they didn't. Because they wanted to be consistent.



The "/A /B" style was popular in DOS and the early versions of Windows. That's why old and "historic" Windows utilities like chkdsk still use that format.



Unix on the other hand, tended to use the -A or --parameter-name style, and it gradually caught on with other developers. As you saw with shutdown.exe, even Windows is adopting the style.
mahala
2016-10-06 16:25:27 UTC
shall we are saying you gave this command on the command instantaneous: MyProgram.exe myFileToOpen.txt With this because of the fact the command, argc would be 2 because of the fact it has this device's call and the greater parameter you handed. in the arguments, argv[0] is often the call of the executable application, typed as you probably did on the command instantaneous. So it will be "MyProgram.exe". the 2d parameter would be saved in argv[a million]. in the command I gave you, it is going to incorporate "myFileToOpen.txt". To open a document handed because of the fact the parameter on the command instantaneous, you pick your application to do some thing like this: #contain int important( int argc, char* argv[] ) { document *fp; //make confident they gave you a document call in the previous attempting to open it. if( argc != 2) //then you definitely did no longer bypass a million and in easy terms one parameter because of the fact the document call { printf( "errors. superb format is: MyProgram.exe FileNamen" ); return a million; } fp = fopen( argv[a million], "w") if ( fp == NULL ) //make confident document opened wisely { printf( "errors. would desire to no longer open document.n" ); return 2; } else { fprintf( fp, "Printing this text to the document."); } fclose(fp); return 0; } Now, you assert argv[a million] does not have something. Are you working your application from the command instantaneous or are you working it from interior of an IDE (or yet another application). in case you run it from the command instantaneous, you may somewhat style the greater argument your self. even inspite of the undeniable fact that, once you run it from interior of yet another application (seen Studio, Code::Blocks, Dev-C++, Eclipse, and so on), then you definitely will would desire to alter the settings so it passes those parameters to this device for you once you run it. distinctive courses try this in any different case... so i won't permit you know here. until you alter the putting to bypass that parameter, it won't bypass it and you will in easy terms have a value in argv[0] and argc will equivalent a million. additionally take word that some IDE's have Debug and launch modes.... changing the enter parameter on one mode, won't unavoidably exchange it on the different mode.
anonymous
2009-08-28 11:10:02 UTC
Usually a ' - ' preceeds a value which is used as input to the command line program, the value could be a number, string of characters, I think the '/' is an alternative to '-'.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...