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
The `__argc` global variable is a count of the number of command-line arguments passed to the program. `__argv` is a pointer to an array of single-byte-character or multi-byte-character strings that contain the program arguments, and `__wargv` is a pointer to an array of wide-character strings that contain the program arguments. These global variables provide the arguments to `main` or `wmain`.
15
17
16
18
## Syntax
17
19
18
-
```
20
+
```C
19
21
externint __argc;
20
22
externchar ** __argv;
21
23
externwchar_t ** __wargv;
@@ -27,7 +29,7 @@ In a program that uses the `main` function, `__argc` and `__argv` are initializ
27
29
28
30
For portable code, we recommend you use the arguments passed to `main` to get the command-line arguments in your program.
29
31
30
-
### Generic-Text Routine Mappings
32
+
### Generic-text routine mappings
31
33
32
34
|Tchar.h routine|_UNICODE not defined|_UNICODE defined|
@@ -77,7 +79,7 @@ Also, if the buffer is too small, these functions return **ERANGE**. They do not
77
79
78
80
## Remarks
79
81
80
-
The **getenv_s** function searches the list of environment variables for *varname*. **getenv_s** is not case sensitive in the Windows operating system. **getenv_s** and [_putenv_s](putenv-s-wputenv-s.md) use the copy of the environment that's pointed to by the global variable **_environ** to access the environment. **getenv_s** operates only on the data structures that are accessible to the run-time library and not on the environment "segment" that's created for the process by the operating system. Therefore, programs that use the *envp* argument to [main](../../cpp/main-program-startup.md) or [wmain](../../cpp/main-program-startup.md) might retrieve invalid information.
82
+
The **getenv_s** function searches the list of environment variables for *varname*. **getenv_s** is not case sensitive in the Windows operating system. **getenv_s** and [_putenv_s](putenv-s-wputenv-s.md) use the copy of the environment that's pointed to by the global variable **_environ** to access the environment. **getenv_s** operates only on the data structures that are accessible to the run-time library and not on the environment "segment" that's created for the process by the operating system. Therefore, programs that use the *envp* argument to [main](../../cpp/main-function-command-line-args.md) or [wmain](../../cpp/main-function-command-line-args.md) might retrieve invalid information.
81
83
82
84
**_wgetenv_s** is a wide-character version of **getenv_s**; the argument and return value of **_wgetenv_s** are wide-character strings. The **_wenviron** global variable is a wide-character version of **_environ**.
Returns a pointer to the environment table entry containing *varname*. It is not safe to modify the value of the environment variable using the returned pointer. Use the [_putenv](putenv-wputenv.md) function to modify the value of an environment variable. The return value is **NULL** if *varname* is not found in the environment table.
38
40
39
41
## Remarks
40
42
41
-
The **getenv** function searches the list of environment variables for *varname*. **getenv** is not case sensitive in the Windows operating system. **getenv** and **_putenv** use the copy of the environment pointed to by the global variable **_environ** to access the environment. **getenv** operates only on the data structures accessible to the run-time library and not on the environment "segment" created for the process by the operating system. Therefore, programs that use the *envp* argument to [main](../../cpp/main-program-startup.md) or [wmain](../../cpp/main-program-startup.md) may retrieve invalid information.
43
+
The **getenv** function searches the list of environment variables for *varname*. **getenv** is not case sensitive in the Windows operating system. **getenv** and **_putenv** use the copy of the environment pointed to by the global variable **_environ** to access the environment. **getenv** operates only on the data structures accessible to the run-time library and not on the environment "segment" created for the process by the operating system. Therefore, programs that use the *envp* argument to [main](../../cpp/main-function-command-line-args.md) or [wmain](../../cpp/main-function-command-line-args.md) may retrieve invalid information.
42
44
43
45
If *varname* is **NULL**, this function invokes an invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, this function sets **errno** to **EINVAL** and returns **NULL**.
44
46
@@ -117,6 +119,6 @@ New LIB variable is: c:\mylib;c:\yourlib
117
119
118
120
## See also
119
121
120
-
[Process and Environment Control](../../c-runtime-library/process-and-environment-control.md)<br/>
122
+
[Process and environment control](../../c-runtime-library/process-and-environment-control.md)<br/>
An output parameter, set to point to the character after the last interpreted character. Ignored, if **NULL**.
50
51
51
-
*base*<br/>
52
+
*base*\
52
53
Number base to use.
53
54
54
-
*locale*<br/>
55
+
*locale*\
55
56
Locale to use.
56
57
57
58
## Return Value
58
59
59
-
**strtol** returns the value represented in the string *strSource*, except when the representation would cause an overflow, in which case it returns **LONG_MAX** or**LONG_MIN**. **strtol** returns 0 if no conversion can be performed. **wcstol** returns values analogously to **strtol**. For both functions,**errno**is set to **ERANGE** if overflow or underflow occurs.
60
+
**strtol**, **wcstol**, **_strtol_l**, and**_wcstol_l** return the value represented in *string*. They return 0 if no conversion is possible. When the representation would cause an overflow, they return**LONG_MAX**or **LONG_MIN**.
60
61
61
-
See [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) for more information on these and other return codes.
62
+
**errno** is set to **ERANGE** if overflow or underflow occurs. It's set to **EINVAL** if *string* is **NULL**. Or, if *base* is nonzero and less than 2, or greater than 36. For more information on **ERANGE**, **EINVAL**, and other return codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
62
63
63
64
## Remarks
64
65
65
-
The **strtol** function converts *strSource*to a **long**. **strtol** stops reading the string*strSource* at the first character it cannot recognize as part of a number. This may be the terminatingnull character, or it may be the first numeric character greater than or equal to *base*.
66
+
The **strtol**, **wcstol**, **_strtol_l**, and **_wcstol_l** functions convert *string*to a **long**. They stop reading *string* at the first character not recognized as part of a number. It may be the terminating-null character, or the first alphanumeric character greater than or equal to *base*.
66
67
67
-
**wcstol** is a wide-character version of **strtol**; its *strSource* argument is a wide-character string. These functions behave identically otherwise.
68
+
**wcstol** and **_wcstol_l** are wide-character versions of **strtol** and **_strtol_l**. Their *string* argument is a wide-character string. These functions behave identically to **strtol** and **_strtol_l** otherwise. The locale's **LC_NUMERIC** category setting determines recognition of the radix character (the fractional marker or decimal point) in *string*. The functions **strtol** and **wcstol** use the current locale. **_strtol_l** and **_wcstol_l** use the locale passed in instead. For more information, see [setlocale] and [Locale](../../c-runtime-library/locale.md).
69
+
70
+
When *end_ptr* is **NULL**, it's ignored. Otherwise, a pointer to the character that stopped the scan is stored at the location pointed to by *end_ptr*. No conversion is possible if no valid digits are found, or an invalid base is specified. The value of *string* is then stored at the location pointed to by *end_ptr*.
71
+
72
+
**strtol** expects *string* to point to a string of the following form:
Square brackets (`[ ]`) surround optional elements. Curly braces and a vertical bar (`{ | }`) surround alternatives for a single element. *whitespace* may consist of space and tab characters, which are ignored. *alphanumerics* are decimal digits or the letters 'a' through 'z' (or 'A' through 'Z'). The first character that doesn't fit this form stops the scan. If *base* is between 2 and 36, then it's used as the base of the number. If *base* is 0, the initial characters of the string pointed to by *string* are used to determine the base. If the first character is 0, and the second character isn't 'x' or 'X', the string is interpreted as an octal integer. If the first character is '0' and the second character is 'x' or 'X', the string is interpreted as a hexadecimal integer. If the first character is '1' through '9', the string is interpreted as a decimal integer. The letters 'a' through 'z' (or 'A' through 'Z') are assigned the values 10 through 35. The scan only allows letters whose values are less than *base*. The first character outside the range of the base stops the scan. For example, suppose *string* starts with "01". If *base* is 0, the scanner assumes it's an octal integer. An '8' or '9' character stops the scan.
68
77
69
78
### Generic-Text Routine Mappings
70
79
@@ -73,37 +82,29 @@ The **strtol** function converts *strSource* to a **long**. **strtol** stops rea
The current locale's **LC_NUMERIC** category setting determines recognition of the radix character in *strSource*; for more information, see [setlocale](setlocale-wsetlocale.md). The functions without the **_l** suffix use the current locale; **_strtol_l** and **_wcstol_l** are identical to the corresponding functions without the **_l** suffix except that they use the locale passed in instead. For more information, see [Locale](../../c-runtime-library/locale.md).
77
-
78
-
If *endptr* is not **NULL**, a pointer to the character that stopped the scan is stored at the location pointed to by *endptr*. If no conversion can be performed (no valid digits were found or an invalid base was specified), the value of *strSource* is stored at the location pointed to by *endptr*.
79
-
80
-
**strtol** expects *strSource* to point to a string of the following form:
A *whitespace* may consist of space and tab characters, which are ignored; *digits* are one or more decimal digits; *letters* are one or more of the letters 'a' through 'z' (or 'A' through 'Z'). The first character that does not fit this form stops the scan. If *base* is between 2 and 36, then it is used as the base of the number. If *base* is 0, the initial characters of the string pointed to by *strSource* are used to determine the base. If the first character is 0 and the second character is not 'x' or 'X', the string is interpreted as an octal integer. If the first character is '0' and the second character is 'x' or 'X', the string is interpreted as a hexadecimal integer. If the first character is '1' through '9', the string is interpreted as a decimal integer. The letters 'a' through 'z' (or 'A' through 'Z') are assigned the values 10 through 35; only letters whose assigned values are less than *base* are permitted. The first character outside the range of the base stops the scan. For example, if *base* is 0 and the first character scanned is '0', an octal integer is assumed and an '8' or '9' character will stop the scan.
85
-
86
85
## Requirements
87
86
88
87
|Routine|Required header|
89
88
|-------------|---------------------|
90
89
|**strtol**|\<stdlib.h>|
91
90
|**wcstol**|\<stdlib.h> or \<wchar.h>|
92
91
|**_strtol_l**|\<stdlib.h>|
92
+
|**_wcstol_l**|\<stdlib.h> or \<wchar.h>|
93
93
94
-
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
94
+
The **_strtol_l** and **_wcstol_l** functions are Microsoft-specific, not part of the Standard C library. For additional compatibility information, see [Compatibility](../compatibility.md).
95
95
96
96
## Example
97
97
98
98
See the example for [strtod](strtod-strtod-l-wcstod-wcstod-l.md).
Copy file name to clipboardExpand all lines: docs/cpp/initializers.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,7 +165,7 @@ int main() {
165
165
}
166
166
```
167
167
168
-
For more information about initialization of global static objects, see [Additional Startup Considerations](../cpp/additional-startup-considerations.md).
168
+
For more information about initialization of global static objects, see [main function and command-line arguments](main-function-command-line-args.md).
169
169
170
170
### Value initialization
171
171
@@ -532,4 +532,4 @@ References that are not qualified with either the **const** or **volatile** keyw
532
532
533
533
### Initialization of external variables
534
534
535
-
Declarations of automatic, static, and external variables can contain initializers. However, declarations of external variables can contain initializers only if the variables are not declared as **extern**.
535
+
Declarations of automatic, static, and external variables can contain initializers. However, declarations of external variables can contain initializers only if the variables are not declared as **extern**.
0 commit comments