Important Notice
  
  
    The pages on this site contain documentation for very old MS-DOS software,
    purely for historical purposes.
    If you're looking for up-to-date documentation, particularly for programming,
    you should not rely on the information found here, as it will be woefully
    out of date.
  
 
 Parsing Command-Line Arguments
                                             ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
 
     Microsoft C start-up code uses the following rules when parsing
     arguments given on the DOS or OS/2 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, then 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, then 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 Wild-Card Arguments►
               ◄Suppressing Command-Line Processing►
                                    -♦-