getline
从逐行的输入流来提取字符串。
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>& _Istr,
basic_string<CharType, Traits, Allocator>& _Str
);
template<class CharType, class Traits, class Allocator>
basic_istream< CharType, Traits >& getline(
basic_istream< CharType, Traits >& _Istr,
basic_string< CharType, Traits, Allocator >& _Str,
CharType _Delim
);
template<class Allocator, class Traits, class Allocator>
basic_istream< Allocator, Traits >& getline(
basic_istream< Allocator, Traits >&& _Istr,
basic_string< Allocator, Traits, Allocator >& _Str
);
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& getline(
basic_istream<CharType, Traits>&& _Istr,
basic_string<CharType, Traits, Allocator>& _Str,
const CharType _Delim
);
参数
_Istr
字符串将提取的输入流。_Str
读取输入流字符的字符串。_Delim
行分隔符。
返回值
第一个函数返回 getline( _Istr, _Str, _Istr。widen(“\n”)。
第二个函数使用从流提取的元素序列替换序列控件由 _Str_Istr。
其余的功能前面是模拟设置为,但是,与 Lvalue和Rvalues。
备注
跟踪测试的顺序,提取终止:
在文件末尾。
在函数提取与 delim相等的元素后,,在元素不会使也不会追加到控件序列情况下。
在函数提取 str.max_size 元素后,,在函数调用 setstate情况下 (ios_base::failbit)。
如果函数不提取元素,它调用 setstate(failbit)。 在任一情况下,它将返回 _Istr。
示例
有关使用示例 getline参见 string::getline 。
要求
**标题:**string
命名空间: std