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
{{ message }}
Repository navigation
Commit af9c88b
Browse filesBrowse the repository at this point in the historyBrowse files
These are arguments for the [exit](reference/exit-exit-exit.md) and [_exit](reference/exit-exit-exit.md) functions, and the return values for the [atexit](reference/atexit.md) and [_onexit](reference/onexit-onexit-m.md) functions.
18
+
These are arguments for the [`exit`](reference/exit-exit-exit.md) and [`_exit`](reference/exit-exit-exit.md) functions, and the return values for the [`atexit`](reference/atexit.md) and [`_onexit`](reference/onexit-onexit-m.md) functions.
Verifies that a specified pointer is in a heap allocated by some C run-time library, but not necessarily by the caller's CRT library. In versions of the CRT before Visual Studio 2010, this verifies that the specified pointer is in the local heap (debug version only).
16
15
@@ -24,30 +23,30 @@ int _CrtIsValidHeapPointer(
24
23
25
24
### Parameters
26
25
27
-
*userData*<br/>
26
+
*`userData`*\
28
27
Pointer to the beginning of an allocated memory block.
29
28
30
29
## Return Value
31
30
32
-
**_CrtIsValidHeapPointer** returns TRUE if the specified pointer is in the heap shared by all CRT library instances. In versions of the CRT before Visual Studio 2010, this returns TRUE if the specified pointer is in the local heap. Otherwise, the function returns FALSE.
31
+
**`_CrtIsValidHeapPointer`** returns `TRUE` if the specified pointer is in the heap shared by all CRT library instances. In versions of the CRT before Visual Studio 2010, this returns `TRUE` if the specified pointer is in the local heap. Otherwise, the function returns `FALSE`.
33
32
34
33
## Remarks
35
34
36
-
We do not recommend that you use this function. Starting with the Visual Studio 2010 CRT library, all CRT libraries share one OS heap, the *process heap*. The **_CrtIsValidHeapPointer** function reports whether the pointer was allocated in a CRT heap, but not that it was allocated by the caller's CRT library. For example, consider a block allocated by using the Visual Studio 2010 version of the CRT library. If the **_CrtIsValidHeapPointer** function exported by the Visual Studio 2012 version of the CRT library tests the pointer, it returns TRUE. This is no longer a useful test. In versions of the CRT library before Visual Studio 2010, the function is used to ensure that a specific memory address is within the local heap. The local heap refers to the heap created and managed by a particular instance of the C run-time library. If a dynamic-link library (DLL) contains a static link to the run-time library, it has its own instance of the run-time heap, and therefore its own heap, independent of the application's local heap. When [_DEBUG](../../c-runtime-library/debug.md) is not defined, calls to **_CrtIsValidHeapPointer** are removed during preprocessing.
35
+
We don't recommend that you use this function. Starting with the Visual Studio 2010 CRT library, all CRT libraries share one OS heap, the *process heap*. The **`_CrtIsValidHeapPointer`** function reports whether the pointer was allocated in a CRT heap, but not that it was allocated by the caller's CRT library. For example, consider a block allocated by using the Visual Studio 2010 version of the CRT library. If the **`_CrtIsValidHeapPointer`** function exported by the Visual Studio 2012 version of the CRT library tests the pointer, it returns `TRUE`. This is no longer a useful test. In versions of the CRT library before Visual Studio 2010, the function is used to ensure that a specific memory address is within the local heap. The local heap refers to the heap created and managed by a particular instance of the C run-time library. If a dynamic-link library (DLL) contains a static link to the run-time library, it has its own instance of the run-time heap, and therefore its own heap, independent of the application's local heap. When [`_DEBUG`](../../c-runtime-library/debug.md) isn't defined, calls to **`_CrtIsValidHeapPointer`** are removed during preprocessing.
37
36
38
-
Because this function returns TRUE or FALSE, it can be passed to one of the [_ASSERT](assert-asserte-assert-expr-macros.md) macros to create a simple debugging error handling mechanism. The following example causes an assertion failure if the specified address is not located within the local heap:
37
+
Because this function returns `TRUE` or `FALSE`, it can be passed to one of the [`_ASSERT`](assert-asserte-assert-expr-macros.md) macros to create a simple debugging error handling mechanism. The following example causes an assertion failure if the specified address isn't located within the local heap:
39
38
40
39
```C
41
40
_ASSERTE( _CrtIsValidHeapPointer( userData ) );
42
41
```
43
42
44
-
For more information about how **_CrtIsValidHeapPointer** can be used with other debug functions and macros, see [Macros for Reporting](/visualstudio/debugger/macros-for-reporting). For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see [CRT Debug Heap Details](/visualstudio/debugger/crt-debug-heap-details).
43
+
For more information about how **`_CrtIsValidHeapPointer`** can be used with other debug functions and macros, see [Macros for Reporting](/visualstudio/debugger/macros-for-reporting). For information about how memory blocks are allocated, initialized, and managed in the debug version of the base heap, see [CRT Debug Heap Details](/visualstudio/debugger/crt-debug-heap-details).
45
44
46
45
## Requirements
47
46
48
47
|Routine|Required header|
49
48
|-------------|---------------------|
50
-
|**_CrtIsValidHeapPointer**|\<crtdbg.h>|
49
+
|**`_CrtIsValidHeapPointer`**|`<crtdbg.h>`|
51
50
52
51
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
53
52
@@ -57,7 +56,7 @@ Debug versions of [C run-time libraries](../../c-runtime-library/crt-library-fea
57
56
58
57
## Example
59
58
60
-
The following example demonstrates how to test whether memory is valid when it is used with C run-time libraries before Visual Studio 2010. This example is provided for users of legacy CRT library code.
59
+
The following example demonstrates how to test whether memory is valid when it's used with C run-time libraries before Visual Studio 2010. This example is provided for users of legacy CRT library code.
61
60
62
61
```C
63
62
// crt_isvalid.c
@@ -111,4 +110,4 @@ my_pointer is within the local heap.
Creates a second file descriptor for an open file (**_dup**), or reassigns a file descriptor (**_dup2**).
14
+
Creates a second file descriptor for an open file (**`_dup`**), or reassigns a file descriptor (**`_dup2`**).
16
15
17
16
## Syntax
18
17
@@ -23,23 +22,23 @@ int _dup2( int fd1, int fd2 );
23
22
24
23
### Parameters
25
24
26
-
*fd*, *fd1*<br/>
25
+
*`fd`*, *`fd1`*\
27
26
File descriptors referring to open file.
28
27
29
-
*fd2*<br/>
28
+
*`fd2`*\
30
29
Any file descriptor.
31
30
32
31
## Return Value
33
32
34
-
**_dup** returns a new file descriptor. **_dup2** returns 0 to indicate success. If an error occurs, each function returns -1 and sets **errno** to **EBADF** if the file descriptor is invalid or to **EMFILE** if no more file descriptors are available. In the case of an invalid file descriptor, the function also invokes the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md).
33
+
**`_dup`** returns a new file descriptor. **`_dup2`** returns 0 to indicate success. If an error occurs, each function returns -1 and sets **`errno`** to **`EBADF`** if the file descriptor is invalid or to **`EMFILE`** if no more file descriptors are available. In the case of an invalid file descriptor, the function also invokes the invalid parameter handler, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md).
35
34
36
-
For more information about these and other return codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
35
+
For more information about these and other return codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
37
36
38
37
## Remarks
39
38
40
-
The **_dup** and **_dup2** functions associate a second file descriptor with a currently open file. These functions can be used to associate a predefined file descriptor, such as that for **stdout**, with a different file. Operations on the file can be carried out using either file descriptor. The type of access allowed for the file is unaffected by the creation of a new descriptor. **_dup** returns the next available file descriptor for the given file. **_dup2** forces *fd2* to refer to the same file as *fd1*. If *fd2* is associated with an open file at the time of the call, that file is closed.
39
+
The **`_dup`** and **`_dup2`** functions associate a second file descriptor with a currently open file. These functions can be used to associate a predefined file descriptor, such as that for **`stdout`**, with a different file. Operations on the file can be carried out using either file descriptor. The type of access allowed for the file is unaffected by the creation of a new descriptor. **`_dup`** returns the next available file descriptor for the given file. **`_dup2`** forces *`fd2`* to refer to the same file as *`fd1`*. If *`fd2`* is associated with an open file at the time of the call, that file is closed.
41
40
42
-
Both **_dup** and **_dup2** accept file descriptors as parameters. To pass a stream (`FILE *`) to either of these functions, use [_fileno](fileno.md). The **fileno** routine returns the file descriptor currently associated with the given stream. The following example shows how to associate **stderr** (defined as `FILE *` in Stdio.h) with a file descriptor:
41
+
Both **`_dup`** and **`_dup2`** accept file descriptors as parameters. To pass a stream (`FILE *`) to either of these functions, use [`_fileno`](fileno.md). The **`fileno`** routine returns the file descriptor currently associated with the given stream. The following example shows how to associate **`stderr`** (defined as `FILE *` in `stdio.h`) with a file descriptor:
43
42
44
43
```C
45
44
int cstderr = _dup( _fileno( stderr ));
@@ -51,10 +50,10 @@ By default, this function's global state is scoped to the application. To change
51
50
52
51
|Routine|Required header|
53
52
|-------------|---------------------|
54
-
|**_dup**|\<io.h>|
55
-
|**_dup2**|\<io.h>|
53
+
|**`_dup`**|`<io.h>`|
54
+
|**`_dup2`**|`<io.h>`|
56
55
57
-
The console is not supported in Universal Windows Platform (UWP) apps. The standard stream handles that are associated with the console, **stdin**, **stdout**, and **stderr**, must be redirected before C run-time functions can use them in UWP apps. For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
56
+
The console isn't supported in Universal Windows Platform (UWP) apps. The standard stream handles that are associated with the console, **`stdin`**, **`stdout`**, and **`stderr`**, must be redirected before C run-time functions can use them in UWP apps. For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/freopen-wfreopen.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ By default, this function's global state is scoped to the application. To change
63
63
64
64
|*`mode`*|Access|
65
65
|-|-|
66
-
|**`"r"`**| Opens for reading. If the file doesn't exist or cannot be found, the **`freopen`** call fails. |
66
+
|**`"r"`**| Opens for reading. If the file doesn't exist or can’t be found, the **`freopen`** call fails. |
67
67
|**`"w"`**| Opens an empty file for writing. If the given file exists, its contents are destroyed. |
68
68
|**`"a"`**| Opens for writing at the end of the file (appending) without removing the end-of-file (EOF) marker before new data is written to the file. Creates the file if it doesn't exist. |
69
69
|**`"r+"`**| Opens for both reading and writing. The file must exist. |
@@ -72,7 +72,7 @@ By default, this function's global state is scoped to the application. To change
72
72
73
73
Use the **`"w"`** and **`"w+"`** types with care, as they can destroy existing files. Starting in C11, you can append **`"x"`** to **`"w"`** or **`"w+"`** to cause the function fail if the file exists, instead of overwriting it.
74
74
75
-
When a file is opened with the **`"a"`** or **`"a+"`** access type, all write operations take place at the end of the file. Although the file pointer can be repositioned using [`fseek`](fseek-fseeki64.md) or [`rewind`](rewind.md), the file pointer is always moved back to the end of the file before any write operation is carried out. Thus, existing data cannot be overwritten.
75
+
When a file is opened with the **`"a"`** or **`"a+"`** access type, all write operations take place at the end of the file. Although the file pointer can be repositioned using [`fseek`](fseek-fseeki64.md) or [`rewind`](rewind.md), the file pointer is always moved back to the end of the file before any write operation is carried out. Thus, existing data can’t be overwritten.
76
76
77
77
The **`"a"`** mode doesn't remove the EOF marker before appending to the file. After appending has occurred, the MS-DOS TYPE command only shows data up to the original EOF marker and not any data appended to the file. The **`"a+"`** mode does remove the EOF marker before appending to the file. After appending, the MS-DOS TYPE command shows all data in the file. The **`"a+"`** mode is required for appending to a stream file that is terminated with the CTRL+Z EOF marker.
78
78
@@ -83,7 +83,7 @@ When the **`"r+"`**, **`"w+"`**, or **`"a+"`** access type is specified, both re
83
83
|**`t`**| Open in text (translated) mode. |
84
84
|**`b`**| Open in binary (untranslated) mode; translations involving carriage-return and line feed characters are suppressed. |
85
85
86
-
In text (translated) mode, carriage return-line feed (CR-LF) combinations are translated into single line feed (LF) characters on input; LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading or for writing and reading with **`"a+"`**, the run-time library checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using [`fseek`](fseek-fseeki64.md) and [ftell](ftell-ftelli64.md) to move within a file may cause [`fseek`](fseek-fseeki64.md) to behave improperly near the end of the file. Don't use the **`t`** option if you want ANSI portability because it's a Microsoft extension.
86
+
In text (translated) mode, carriage return-line feed (CR-LF) combinations are translated into single line feed (LF) characters on input; LF characters are translated to CR-LF combinations on output. Also, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading or for writing and reading with **`"a+"`**, the run-time library checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using [`fseek`](fseek-fseeki64.md) and [`ftell`](ftell-ftelli64.md) to move within a file may cause [`fseek`](fseek-fseeki64.md) to behave improperly near the end of the file. Don't use the **`t`** option if you want ANSI portability because it's a Microsoft extension.
87
87
88
88
If **`t`** or **`b`** isn't given in *`mode`*, the default translation mode is defined by the global variable [`_fmode`](../../c-runtime-library/fmode.md). If **`t`** or **`b`** is prefixed to the argument, the function fails and returns **`NULL`**.
Copy file name to clipboardExpand all lines: docs/c-runtime-library/reference/getcwd.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,12 @@ api_type: ["DLLExport"]
8
8
topic_type: ["apiref"]
9
9
f1_keywords: ["getcwd"]
10
10
helpviewer_keywords: ["getcwd function"]
11
-
ms.assetid: c740ab06-9ba0-4036-a025-ce3acded3ffe
12
11
---
13
-
# getcwd
12
+
# `getcwd`
14
13
15
-
The Microsoft-implemented POSIX function name `getcwd` is a deprecated alias for the [_getcwd](getcwd-wgetcwd.md) function. By default, it generates [Compiler warning (level 3) C4996](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md). The name is deprecated because it doesn't follow the Standard C rules for implementation-specific names. However, the function is still supported.
14
+
The Microsoft-implemented POSIX function name `getcwd` is a deprecated alias for the [`_getcwd`](getcwd-wgetcwd.md) function. By default, it generates [Compiler warning (level 3) C4996](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md). The name is deprecated because it doesn't follow the Standard C rules for implementation-specific names. However, the function is still supported.
16
15
17
-
We recommend you use [_getcwd](getcwd-wgetcwd.md) instead. Or, you can continue to use this function name, and disable the warning. For more information, see [Turn off the warning](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md#turn-off-the-warning) and [POSIX function names](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md#posix-function-names).
16
+
We recommend you use [`_getcwd`](getcwd-wgetcwd.md) instead. Or, you can continue to use this function name, and disable the warning. For more information, see [Turn off the warning](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md#turn-off-the-warning) and [POSIX function names](../../error-messages/compiler-warnings/compiler-warning-level-3-c4996.md#posix-function-names).
18
17
19
18
> [!IMPORTANT]
20
19
> This API cannot be used in applications that execute in the Windows Runtime. For more information, see [CRT functions not supported in Universal Windows Platform apps](../../cppcx/crt-functions-not-supported-in-universal-windows-platform-apps.md).
0 commit comments