You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,15 +13,17 @@ Microsoft C startup code uses the following rules when interpreting arguments gi
12
13
13
14
- Arguments are delimited by white space, which is either a space or a tab.
14
15
15
-
-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. Note that the caret (**^**) is not recognized as an escape character or delimiter.
16
+
-The first argument (`argv[0]`) is treated specially. It represents the program name. Because it must be a valid pathname, parts surrounded by double quote marks (**`"`**) are allowed. The double quote marks aren't included in the `argv[0]` output. The parts surrounded by double quote marks prevent interpretation of a space or tab character as the end of the argument. The later rules in this list don't apply.
16
17
17
-
- A double quotation mark preceded by a backslash, **\\"**, is interpreted as a literal double quotation mark (**"**).
18
+
- A string surrounded by double quote marks is interpreted as a single argument, whether or not it contains white space. A quoted string can be embedded in an argument. The caret (**`^`**) isn't recognized as an escape character or delimiter. Within a quoted string, a pair of double quote marks is interpreted as a single escaped double quote mark. If the command line ends before a closing double quote mark is found, then all the characters read so far are output as the last argument.
18
19
19
-
-Backslashes are interpreted literally, unless they immediately precede a double quotation mark.
20
+
-A double quote mark preceded by a backslash (**`\"`**) is interpreted as a literal double quote mark (**`"`**).
20
21
21
-
-If an even number of backslashes is followed by a double quotation mark, then one backslash (**\\**) is placed in the `argv` array for every pair of backslashes (**\\\\**), and the double quotation mark (**"**) is interpreted as a string delimiter.
22
+
-Backslashes are interpreted literally, unless they immediately precede a double quote mark.
22
23
23
-
- If an odd number of backslashes is followed by a double quotation mark, then one backslash (**\\**) is placed in the `argv` array for every pair of backslashes (**\\\\**) and the double quotation mark is interpreted as an escape sequence by the remaining backslash, causing a literal double quotation mark (**"**) to be placed in `argv`.
24
+
- If an even number of backslashes is followed by a double quote mark, then one backslash (**`\`**) is placed in the `argv` array for every pair of backslashes (**`\\`**), and the double quote mark (**`"`**) is interpreted as a string delimiter.
25
+
26
+
- If an odd number of backslashes is followed by a double quote mark, then one backslash (**`\`**) is placed in the `argv` array for every pair of backslashes (**`\\`**). The double quote mark is interpreted as an escape sequence by the remaining backslash, causing a literal double quote mark (**`"`**) to be placed in `argv`.
24
27
25
28
This list illustrates the rules above by showing the interpreted result passed to `argv` for several examples of command-line arguments. The output listed in the second, third, and fourth columns is from the ARGS.C program that follows the list.
26
29
@@ -31,13 +34,13 @@ This list illustrates the rules above by showing the interpreted result passed t
31
34
|`a\\\b d"e f"g h`|`a\\\b`|`de fg`|`h`|
32
35
|`a\\\"b c d`|`a\"b`|`c`|`d`|
33
36
|`a\\\\"b c" d e`|`a\\b c`|`d`|`e`|
37
+
|`a"b"" c d`|`ab" c d`|||
34
38
35
39
## Example
36
40
37
41
### Code
38
42
39
43
```c
40
-
// Parsing_C_Commandline_args.c
41
44
// ARGS.C illustrates the following variables used for accessing
42
45
// command-line arguments and environment variables:
0 commit comments