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
Returns a stream associated with one end of the created pipe. The other end of the pipe is associated with the spawned command's standard input or standard output. The functions return **NULL** on an error. If the error is an invalid parameter, such as if *command* or *mode* is a null pointer, or *mode* is not a valid mode, **errno** is set to **EINVAL**. See the Remarks section for valid modes.
44
+
Returns a stream associated with one end of the created pipe. The other end of the pipe is associated with the spawned command's standard input or standard output. The functions return **NULL** on an error. If the error is caused by an invalid parameter, **errno** is set to **EINVAL**. See the Remarks section for valid modes.
43
45
44
46
For information about these and other error codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
45
47
46
48
## Remarks
47
49
48
-
The **_popen** function creates a pipe and asynchronously executes a spawned copy of the command processor with the specified string *command*. The character string *mode* specifies the type of access requested, as follows.
50
+
The **_popen** function creates a pipe. It then asynchronously executes a spawned copy of the command processor, and uses *command* as the command line. The character string *mode* specifies the type of access requested, as follows.
49
51
50
52
|Access mode|Description|
51
53
|-|-|
@@ -107,7 +109,7 @@ int main( void )
107
109
108
110
while(fgets(psBuffer, 128, pPipe))
109
111
{
110
-
printf(psBuffer);
112
+
puts(psBuffer);
111
113
}
112
114
113
115
/* Close pipe and print return value of pPipe. */
@@ -122,9 +124,7 @@ int main( void )
122
124
}
123
125
```
124
126
125
-
### Sample Output
126
-
127
-
This output assumes that there is only one file in the current directory with a .c file name extension.
127
+
This output assumes there's only one file in the current directory that has a `.c` file name extension.
128
128
129
129
```Output
130
130
Volume in drive C is CDRIVE
@@ -141,6 +141,6 @@ Process returned 0
141
141
142
142
## See also
143
143
144
-
[Process and Environment Control](../../c-runtime-library/process-and-environment-control.md)<br/>
145
-
[_pclose](pclose.md)<br/>
146
-
[_pipe](pipe.md)<br/>
144
+
[Process and environment control](../../c-runtime-library/process-and-environment-control.md)\
If a valid *locale* and *category* are given, returns a pointer to the string associated with the specified *locale* and *category*. If the *locale* or *category*is not valid, returns a null pointer and the current locale settings of the program are not changed.
41
+
If a valid *locale* and *category* are given, returns a pointer to the string associated with the specified *locale* and *category*. If the *locale* or *category*isn't valid, returns a null pointer, and the current locale settings of the program are unchanged.
40
42
41
43
For example, the call
42
44
@@ -75,7 +77,7 @@ The *category* argument specifies the parts of a program's locale information th
75
77
|**LC_NUMERIC**| Decimal-point character for the formatted output routines (such as **printf**), for the data-conversion routines, and for the non-monetary formatting information returned by **localeconv**. In addition to the decimal-point character, **LC_NUMERIC** sets the thousands separator and the grouping control string returned by [localeconv](localeconv.md). |
76
78
|**LC_TIME**| The **strftime** and **wcsftime** functions. |
77
79
78
-
This function validates the category parameter. If the category parameter is not one of the values given in the previous table, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function sets **errno** to **EINVAL** and returns **NULL**.
80
+
This function validates the category parameter. If the category parameter isn't one of the values given in the previous table, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function sets **errno** to **EINVAL** and returns **NULL**.
79
81
80
82
The *locale* argument is a pointer to a string that specifies the locale. For information about the format of the *locale* argument, see [Locale Names, Languages, and Country/Region Strings](../../c-runtime-library/locale-names-languages-and-country-region-strings.md). If *locale* points to an empty string, the locale is the implementation-defined native environment. A value of **C** specifies the minimal ANSI conforming environment for C translation. The **C** locale assumes that all **char** data types are 1 byte and that their value is always less than 256.
81
83
@@ -85,7 +87,7 @@ At program startup, the equivalent of the following statement is executed:
85
87
86
88
The *locale* argument can take a locale name, a language string, a language string and country/region code, a code page, or a language string, country/region code, and code page. The set of available locale names, languages, country/region codes, and code pages includes all those supported by the Windows NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page value of UTF-7 or UTF-8, **setlocale** will fail, returning **NULL**. The set of locale names supported by **setlocale** are described in [Locale Names, Languages, and Country/Region Strings](../../c-runtime-library/locale-names-languages-and-country-region-strings.md). The set of language and country/region strings supported by **setlocale** are listed in [Language Strings](../../c-runtime-library/language-strings.md) and [Country/Region Strings](../../c-runtime-library/country-region-strings.md). We recommend the locale name form for performance and for maintainability of locale strings embedded in code or serialized to storage. The locale name strings are less likely to be changed by an operating system update than the language and country/region name form.
87
89
88
-
A null pointer that's passed as the *locale* argument tells **setlocale** to query instead of to set the international environment. If the *locale* argument is a null pointer, the program's current locale setting is not changed. Instead, **setlocale** returns a pointer to the string that's associated with the *category* of the thread's current locale. If the *category* argument is **LC_ALL**, the function returns a string that indicates the current setting of each category, separated by semicolons. For example, the sequence of calls
90
+
A null pointer that's passed as the *locale* argument tells **setlocale** to query instead of to set the international environment. If the *locale* argument is a null pointer, the program's current locale setting isn't changed. Instead, **setlocale** returns a pointer to the string that's associated with the *category* of the thread's current locale. If the *category* argument is **LC_ALL**, the function returns a string that indicates the current setting of each category, separated by semicolons. For example, the sequence of calls
which is the string that's associated with the **LC_ALL** category.
105
107
106
-
The following examples pertain to the **LC_ALL** category. Either of the strings ".OCP" and ".ACP" can be used instead of a code page number to specify use of the user-default OEM code page and user-default ANSI code page, respectively.
108
+
The following examples pertain to the **LC_ALL** category. Either of the strings ".OCP" and ".ACP" can be used instead of a code page number to specify use of the user-default OEM code page and user-default ANSI code page for that locale name, respectively.
107
109
108
110
-`setlocale( LC_ALL, "" );`
109
111
110
-
Sets the locale to the default, which is the user-default ANSI code page obtained from the operating system.
112
+
Sets the locale to the default, which is the user-default ANSI code page obtained from the operating system. The locale name is set to the value returned by [GetUserDefaultLocaleName](/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename). The code page is set to the value returned by [GetACP](/windows/win32/api/winnls/nf-winnls-getacp).
111
113
112
114
-`setlocale( LC_ALL, ".OCP" );`
113
115
114
-
Explicitly sets the locale to the current OEM code page obtained from the operating system.
116
+
Sets the locale to the current OEM code page obtained from the operating system. The locale name is set to the value returned by [GetUserDefaultLocaleName](/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename). The code page is set to the [LOCALE_IDEFAULTCODEPAGE](/windows/win32/intl/locale-idefault-constants) value for the user-default locale name by [GetLocaleInfoEx](/windows/win32/api/winnls/nf-winnls-getlocaleinfoex).
115
117
116
118
-`setlocale( LC_ALL, ".ACP" );`
117
119
118
-
Sets the locale to the ANSI code page obtained from the operating system.
120
+
Sets the locale to the ANSI code page obtained from the operating system. The locale name is set to the value returned by [GetUserDefaultLocaleName](/windows/win32/api/winnls/nf-winnls-getuserdefaultlocalename). The code page is set to the [LOCALE_IDEFAULTANSICODEPAGE](/windows/win32/intl/locale-idefault-constants) value for the user-default locale name by [GetLocaleInfoEx](/windows/win32/api/winnls/nf-winnls-getlocaleinfoex).
119
121
120
122
-`setlocale( LC_ALL, "<localename>" );`
121
123
122
-
Sets the locale to the locale name that's indicated by *\<localename>*.
124
+
Sets the locale to the locale name that's indicated by *\<localename>*. The code page is set to the [LOCALE_IDEFAULTANSICODEPAGE](/windows/win32/intl/locale-idefault-constants) value for the specified locale name by [GetLocaleInfoEx](/windows/win32/api/winnls/nf-winnls-getlocaleinfoex).
123
125
124
126
-`setlocale( LC_ALL, "<language>_<country>" );`
125
127
126
-
Sets the locale to the language and country/region indicated by *\<language>* and *\<country>*, together with the default code page obtained from the host operating system.
128
+
Sets the locale to the language and country/region indicated by *\<language>* and *\<country>*, together with the default code page obtained from the host operating system. The code page is set to the [LOCALE_IDEFAULTANSICODEPAGE](/windows/win32/intl/locale-idefault-constants) value for the specified locale name by [GetLocaleInfoEx](/windows/win32/api/winnls/nf-winnls-getlocaleinfoex).
0 commit comments