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 the character read. To indicate a read error or end-of-file condition, **getchar** returns **EOF**, and **getwchar** returns **WEOF**. For **getchar**, use **ferror** or **feof** to check for an error or for end of file.
25
+
Returns the character read. These functions wait for input and don't return until input is available.
26
+
27
+
To indicate a read error or end-of-file condition, **getchar** returns **EOF**, and **getwchar** returns **WEOF**. For **getchar**, use **ferror** or **feof** to check for an error or for end of file.
26
28
27
29
## Remarks
28
30
29
-
Each routine reads a single character from **stdin** and increments the associated file pointer to point to the next character. **getchar** is the same as [_fgetchar](fgetc-fgetwc.md), but it is implemented as a function and as a macro.
31
+
Each routine reads a single character from **stdin** and increments the associated file pointer to point to the next character. **getchar** is the same as [_fgetchar](fgetc-fgetwc.md), but it's implemented as a function and as a macro.
30
32
31
-
These functions lock the calling thread and are therefore thread-safe. For a non-locking version, see [_getchar_nolock, _getwchar_nolock](getchar-nolock-getwchar-nolock.md).
33
+
These functions also lock the calling thread and are thread-safe. For a non-locking version, see [_getchar_nolock, _getwchar_nolock](getchar-nolock-getwchar-nolock.md).
32
34
33
35
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
34
36
@@ -45,7 +47,7 @@ By default, this function's global state is scoped to the application. To change
45
47
|**getchar**|\<stdio.h>|
46
48
|**getwchar**|\<stdio.h> or \<wchar.h>|
47
49
48
-
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 additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
50
+
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 additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
Write formatted data to a string. More secure versions of some of these functions are available; see [sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l](sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md). The secure versions of **swprintf** and **_swprintf_l**do not take a *count* parameter.
14
+
Write formatted data to a string. More secure versions of some of these functions are available; see [sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l](sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md). The secure versions of **swprintf** and **_swprintf_l**take the size of the buffer as a parameter.
15
15
16
16
## Syntax
17
17
@@ -91,9 +91,9 @@ The number of characters written, or -1 if an error occurred. If *buffer* or *fo
91
91
The **sprintf** function formats and stores a series of characters and values in *buffer*. Each *argument* (if any) is converted and output according to the corresponding format specification in *format*. The format consists of ordinary characters and has the same form and function as the *format* argument for [printf](printf-printf-l-wprintf-wprintf-l.md). A null character is appended after the last character written. If copying occurs between strings that overlap, the behavior is undefined.
92
92
93
93
> [!IMPORTANT]
94
-
> Using **sprintf**, there is no way to limit the number of characters written, which means that code using **sprintf** is susceptible to buffer overruns. Consider using the related function [_snprintf](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), which specifies a maximum number of characters to be written to *buffer*, or use [_scprintf](scprintf-scprintf-l-scwprintf-scwprintf-l.md) to determine how large a buffer is required. Also, ensure that *format* is not a user-defined string.
94
+
> Using **sprintf**, there is no way to limit the number of characters written, which means that code using **sprintf** is susceptible to buffer overruns. Consider using the related function [_snprintf](snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md), which specifies a maximum number of characters to write to *buffer*, or use [_scprintf](scprintf-scprintf-l-scwprintf-scwprintf-l.md) to determine how large a buffer is required. Also, ensure that *format* is not a user-defined string.
95
95
96
-
**swprintf** is a wide-character version of **sprintf**; the pointer arguments to **swprintf** are wide-character strings. Detection of encoding errors in **swprintf** may differ from that in **sprintf**. **swprintf** and **fwprintf** behave identically except that **swprintf** writes output to a string rather than to a destination of type **FILE**, and **swprintf** requires the *count* parameter to specify the maximum number of characters to be written. The versions of these functions with the **_l** suffix are identical except that they use the locale parameter passed in instead of the current thread locale.
96
+
**swprintf** is a wide-character version of **sprintf**; the pointer arguments to **swprintf** are wide-character strings. Detection of encoding errors in **swprintf** may differ from **sprintf**. **swprintf** and **fwprintf** behave identically except **swprintf** writes output to a string rather than to a destination of type **FILE**, and **swprintf** requires the *count* parameter to specify the maximum number of characters to write. The versions of these functions with the **_l** suffix are identical except they use the locale parameter passed in instead of the current thread locale.
97
97
98
98
**swprintf** conforms to the ISO C Standard, which requires the second parameter, *count*, of type **size_t**. To force the old nonstandard behavior, define **_CRT_NON_CONFORMING_SWPRINTFS**. In a future version, the old behavior may be removed, so code should be changed to use the new conformant behavior.
The SafeInt library provides several functions that you can use without creating an instance of the [SafeInt class](safeint-class.md). If you want to protect a single mathematical operation from integer overflow, you can use these functions. If you want to protect multiple mathematical operations, you should create `SafeInt` objects. It is more efficient to create `SafeInt` objects than to use these functions multiple times.
11
+
The SafeInt library provides several functions that you can use without creating an instance of the [SafeInt class](safeint-class.md). If you want to protect a single mathematical operation from integer overflow, you can use these functions. If you want to protect multiple mathematical operations, you should create `SafeInt` objects. It's more efficient to create `SafeInt` objects than to use these functions multiple times.
12
12
13
13
These functions enable you to compare or perform mathematical operations on two different types of parameters without having to convert them to the same type first.
14
14
@@ -104,10 +104,10 @@ inline bool SafeDivide (
104
104
### Parameters
105
105
106
106
*t*<br/>
107
-
[in] The divisor. This must be of type T.
107
+
[in] The dividend. This must be of type T.
108
108
109
109
*u*<br/>
110
-
[in] The dividend. This must be of type U.
110
+
[in] The divisor. This must be of type U.
111
111
112
112
*result*<br/>
113
113
[out] The parameter where `SafeDivide` stores the result.
@@ -118,7 +118,7 @@ inline bool SafeDivide (
118
118
119
119
## <aname="safeequals"></a> SafeEquals
120
120
121
-
Compares two numbers to determine whether they are equal.
121
+
Compares two numbers to determine whether they're equal.
122
122
123
123
```cpp
124
124
template<typename T, typename U>
@@ -218,7 +218,7 @@ inline bool SafeLessThan (
218
218
[in] The first number. This must be of type `T`.
219
219
220
220
*u*<br/>
221
-
[in] The second numer. This must be of type `U`.
221
+
[in] The second number. This must be of type `U`.
222
222
223
223
### Return Value
224
224
@@ -314,7 +314,7 @@ inline bool SafeMultiply (
314
314
315
315
## <aname="safenotequals"></a> SafeNotEquals
316
316
317
-
Determines if two numbers are not equal.
317
+
Determines if two numbers aren't equal.
318
318
319
319
```cpp
320
320
template<typename T, typename U>
@@ -334,7 +334,7 @@ inline bool SafeNotEquals (
334
334
335
335
### Return Value
336
336
337
-
**true** if *t* and *u*are not equal; otherwise **false**.
337
+
**true** if *t* and *u*aren't equal; otherwise **false**.
An iterator is an object that can iterate over elements in a C++ Standard Library container and provide access to individual elements. The C++ Standard Library containers all provide iterators so that algorithms can access their elements in a standard way without having to be concerned with the type of container the elements are stored in.
10
10
11
-
You can use iterators explicitly using member and global functions such as `begin()` and `end()` and operators such as **++** and **--** to move forward or backward. You can also use iterators implicitly with a range-for loop or (for some iterator types) the subscript operator **\[]**.
11
+
You can use iterators explicitly using member and global functions such as `begin()` and `end()` and operators such as `++` and `--` to move forward or backward. You can also use iterators implicitly with a range-for loop or (for some iterator types) the subscript operator `[]`.
12
12
13
13
In the C++ Standard Library, the beginning of a sequence or range is the first element. The end of a sequence or range is always defined as one past the last element. The global functions `begin` and `end` return iterators to a specified container. The typical explicit iterator loop over all elements in a container looks like this:
14
14
@@ -33,17 +33,17 @@ for (auto num : vec)
33
33
34
34
There are five categories of iterators. In order of increasing power, the categories are:
35
35
36
-
-**Output**. An *output iterator*`X` can iterate forward over a sequence by using the **++** operator, and can write an element only once, by using the __\*__ operator.
36
+
-**Output**. An *output iterator*`X` can iterate forward over a sequence by using the `++` operator, and can write an element only once, by using the __`*`__ operator.
37
37
38
-
-**Input**. An *input iterator*`X` can iterate forward over a sequence by using the ++ operator, and can read an element any number of times by using the ***** operator. You can compare input iterators by using the **++** and **!=** operators. After you increment any copy of an input iterator, none of the other copies can safely be compared, dereferenced, or incremented thereafter.
38
+
-**Input**. An *input iterator*`X` can iterate forward over a sequence by using the `++` operator, and can read an element any number of times by using the `*` operator. You can compare input iterators by using the `==` and `!=` operators. After you increment any copy of an input iterator, none of the other copies can safely be compared, dereferenced, or incremented afterwards.
39
39
40
-
-**Forward**. A *forward iterator*`X` can iterate forward over a sequence using the ++ operator and can read any element or write non-const elements any number of times by using the ***** operator. You can access element members by using the **->** operator and compare forward iterators by using the **==** and **!=** operators. You can make multiple copies of a forward iterator, each of which can be dereferenced and incremented independently. A forward iterator that is initialized without reference to any container is called a *null forward iterator*. Null forward iterators always compare equal.
40
+
-**Forward**. A *forward iterator*`X` can iterate forward over a sequence using the ++ operator and can read any element or write non-const elements any number of times by using the `*` operator. You can access element members by using the `->` operator and compare forward iterators by using the `==` and `!=` operators. You can make multiple copies of a forward iterator, each of which can be dereferenced and incremented independently. A forward iterator that is initialized without reference to any container is called a *null forward iterator*. Null forward iterators always compare equal.
41
41
42
42
-**Bidirectional**. A *bidirectional iterator*`X` can take the place of a forward iterator. You can, however, also decrement a bidirectional iterator, as in `--X`, `X--`, or `(V = *X--)`. You can access element members and compare bidirectional iterators in the same way as forward iterators.
43
43
44
-
-**Random access**. A *random-access iterator*`X` can take the place of a bidirectional iterator. With a random access iterator you can use the subscript operator **\[]** to access elements. You can use the **+**, **-**, **+=** and **-=** operators to move forward or backward a specified number of elements and to calculate the distance between iterators. You can compare bidirectional iterators by using **==**, **!=**, **\<**, **>**, **\<=**, and **>=**.
44
+
-**Random access**. A *random-access iterator*`X` can take the place of a bidirectional iterator. With a random access iterator, you can use the subscript operator `[]` to access elements. You can use the `+`, `-`, `+=` and `-=` operators to move forward or backward a specified number of elements and to calculate the distance between iterators. You can compare bidirectional iterators by using `==`, `!=`, `<`, `>`, `<=`, and `>=`.
45
45
46
-
All iterators can be assigned or copied. They are assumed to be lightweight objects and are often passed and returned by value, not by reference. Note also that none of the operations previously described can throw an exception when performed on a valid iterator.
46
+
All iterators can be assigned or copied. They're assumed to be lightweight objects and are often passed and returned by value, not by reference. Note also that none of the operations previously described can throw an exception when performed on a valid iterator.
47
47
48
48
The hierarchy of iterator categories can be summarized by showing three sequences. For write-only access to a sequence, you can use any of:
49
49
@@ -71,9 +71,9 @@ Finally, for read/write access to a sequence, you can use any of:
71
71
72
72
An object pointer can always serve as a random-access iterator, so it can serve as any category of iterator if it supports the proper read/write access to the sequence it designates.
73
73
74
-
An iterator `Iterator` other than an object pointer must also define the member types required by the specialization `iterator_traits<Iterator>`. Note that these requirements can be met by deriving `Iterator` from the public base class [iterator](../standard-library/iterator-struct.md).
74
+
An iterator `Iterator` other than an object pointer must also define the member types required by the specialization `iterator_traits<Iterator>`. These requirements can be met by deriving `Iterator` from the public base class [iterator](../standard-library/iterator-struct.md).
75
75
76
-
It is important to understand the promises and limitations of each iterator category to see how iterators are used by containers and algorithms in the C++ Standard Library.
76
+
It's important to understand the promises and limitations of each iterator category to see how iterators are used by containers and algorithms in the C++ Standard Library.
77
77
78
78
> [!NOTE]
79
79
> You can avoid using iterators explicitly by using range-for loops. For more information, see [Range-based for statement](../cpp/range-based-for-statement-cpp.md).
0 commit comments