std::basic_streambuf<CharT,Traits>:: sgetc
From cppreference.net
<
cpp
|
io
|
basic streambuf
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::basic_streambuf
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
int_type sgetc
(
)
;
|
||
从输入序列中读取一个字符。
如果输入序列读取位置不可用,则返回 underflow() 。否则返回 Traits :: to_int_type ( * gptr ( ) ) 。
目录 |
参数
(无)
返回值
由 get pointer 指向的字符值。
示例
运行此代码
#include <iostream> #include <sstream> int main() { std::stringstream stream("Hello, world"); std::cout << "sgetc() returned '" << (char)stream.rdbuf()->sgetc() << "'\n"; std::cout << "peek() returned '" << (char)stream.peek() << "'\n"; std::cout << "get() returned '" << (char)stream.get() << "'\n"; }
输出:
sgetc() returned 'H' peek() returned 'H' get() returned 'H'
参见
|
(C++17 中移除)
|
从输入序列读取一个字符并前移序列
(公开成员函数) |
|
前移输入序列,然后读取一个字符且不再前移
(公开成员函数) |