operator>> (<string>)
템플릿 함수 입력된 스트림에서 문자열을 읽습니다.
template<class CharType, class Traits, class Allocator>
basic_istream<CharType, Traits>& operator>>(
basic_istream<CharType, Traits>& _Istr,
basic_string<CharType, Traits, Allocator>& _Right
);
매개 변수
_Istr
입력된 스트림 시퀀스를 추출 하는 데_Right
입력된 스트림에서 추출 되는 문자열입니다.
반환 값
지정 된 문자열의 값을 읽어 _Istr 를 반환 하 고_Right.
설명
연산자 앞에 오는 공백을 않으면 건너뜁니다.는 skipws 플래그를 설정 합니다.다음 문자가 공백 인지 또는 파일의 끝에 도달할 때까지 다음 문자를 모두 읽습니다.
함수 템플릿의 오버 로드 연산자 >> 제어 순서를 바꾸려면 _Right 스트림에서 추출 요소 시퀀스를 가진 _Istr.압축 풀기를 중지합니다.
파일의 끝에.
함수 추출 후 _Istr. 폭 요소를 값이 아닌 경우.
함수 추출 후 _Istr. max_size 요소.
- 함수 요소 추출 후 ch 의 use_facet<ctype<CharType> >( getloc).( ctype<CharType>::공간, ch) 문자를 다시 넣을 경우에 true입니다.
함수 요소를 추출 하는 경우 호출 setstate(ios_base::failbit).호출을 istr. 폭(0)를 반환 하 고 *이.
예제
// string_op_read_.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
string c0;
cout << "Input a string c0 ( try: Fibonacci numbers ): ";
cin >> c0;
cout << "The string entered is c0 = " << c0 << endl;
}
입력
Fibonacci numbers
샘플 출력
Input a string c0 ( try: Fibonacci numbers ): Fibonacci numbers
The string entered is c0 = Fibonacci
요구 사항
헤더: <string>
네임 스페이스: std