A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/char_traits::eof below:

public static member function

<string>

std::char_traits::eof
static constexpr int_type eof() noexcept;

End-of-File character

Returns the End-of-File value.

The End-of-File value is a special value used by many standard functions to represent an invalid character; Its value shall not compare equal to any of the values representable with char_type (as if transformed with member int_type and compared with member eq_int_type).

For the standard specializations of char_traits it returns:


specialization value returned by eof() char EOF wchar_t WEOF char16_t A value that is not a valid UTF-16 code unit. char32_t A value that is not a valid Unicode code point.
Parameters none

Return Value The End-of-File value.
Member type int_type is an integral type that can represent this value or any valid character value.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// char_traits::eof
#include <iostream>   // std::wcin, std::wcout
#include <string>     // std::wstring, std::char_traits

int main () {
  std::wcout << "Please enter some text: ";

  if (std::wcin.peek() == std::char_traits<wchar_t>::eof()) {
    std::wcout << "Reading error";
  }
  else {
    std::wstring ws;
    std::getline (std::wcin,ws);
    std::wcout << "You entered a word: " << ws << '\n';
  }

  return 0;
}

Complexity Constant.

Exception safetyNo-throw guarantee: this member function never throws exceptions.

See also
char_traits::not_eof
Not End-of-File character (public static member function)
EOF
End-of-File (constant)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4