GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_istream::peek(3) C++ Standard Libary std::basic_istream::peek(3)

std::basic_istream::peek - std::basic_istream::peek


int_type peek();


Behaves as UnformattedInputFunction. After constructing and testing the sentry
object, reads the next character from the input stream without extracting it.


(none)


If good() == true, returns the next character as obtained by rdbuf()->sgetc()


Otherwise, returns Traits::eof().


failure if an error occurred (the error state flag is not goodbit) and exceptions()
is set to throw for that state.


If an internal operation throws an exception, it is caught and badbit is set. If
exceptions() is set for badbit, the exception is rethrown.

// Run this code


#include <sstream>
#include <iostream>
int main()
{
std::istringstream s1("Hello, world.");
char c1 = s1.peek();
char c2 = s1.get();
std::cout << "Peeked: " << c1 << " got: " << c2 << '\n';
}


Peeked: H got: H


sgetc reads one character from the input sequence without advancing the sequence
(public member function of std::basic_streambuf<CharT,Traits>)
get extracts characters
(public member function)
unget unextracts a character
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.