C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Parsing Command-Line Arguments
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
     Microsoft C startup code uses the following rules when parsing
     arguments given on the DOS command line:
 
        ■ Arguments are delimited by white space, which is either a
          space or a tab.
 
        ■ The caret character, ^, is not recognized as an escape
          character or delimiter. The character is handled completely
          by the command-line parser in the operating system before
          being passed to the argv array in the program.
 
        ■ A string surrounded by double quotation marks is interpreted
          as a single argument, regardless of white space contained
          within. A quoted string can be embedded in an argument.
 
        ■ A double quotation mark preceded by a backslash, \", is
          interpreted as a literal " character.
 
        ■ Backslashes are interpreted literally, unless they
          immediately precede a double quotation mark.
 
          If an even number of backslashes is followed by a double
          quotation mark, one \ is placed in the argv array
          for every \\ pair, and the " is interpreted as a string
          delimiter.
 
          If an odd number of backslashes is followed by a double
          quotation mark, one \ is placed in the argv array
          for every \\ pair, and the " is escaped by the \ remaining,
          causing a literal " to be placed in argv.
 
     The following shows the interpreted result passed to argv for
     several examples of command-line arguments:
 
     Command-Line Input     argv[1]     argv[2]     argv[3]
 
     "a b c" d e            a b c       d           e
     "a b \" c" "\\" d      a b " c     \           d
     a\\\b d"e f"g h        a\\\b       de fg       h
     a\\\"b c d             a\"b        c           d
     a\\\\"b c" d e         a\\b c      d           e
 
     See also: Expanding Wildcard Arguments
               Suppressing Command-Line Processing
                                    -♦-