public static member function
<string>
std::char_traits::eofstatic 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:
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;
}
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