Namespaces
Variants

std::ios_base:: seekdir

From cppreference.net
typedef /*implementation defined*/ seekdir ;
static constexpr seekdir beg = /*implementation defined*/

static constexpr seekdir end = /*implementation defined*/

static constexpr seekdir cur = /*implementation defined*/

파일 탐색 방향 유형을 지정합니다. 다음 상수들이 정의되어 있습니다:

상수 설명
beg 스트림의 시작
end 스트림의 끝
cur 스트림 위치 표시자의 현재 위치

예제

#include <iostream>
#include <sstream>
#include <string>
int main()
{
    std::istringstream in("Hello, World!");
    std::string word1, word2, word3, word4, word5;
    in >> word1;
    in.seekg(0, std::ios_base::beg); // <- 되감기
    in >> word2;
    in.seekg(1, std::ios_base::cur); // -> 현재 위치에서 끝 방향으로 탐색
    in >> word3;
    in.seekg(-6, std::ios_base::cur); // <- 현재 위치(끝)에서 시작 방향으로 탐색
    in >> word4;
    in.seekg(-6, std::ios_base::end); // <- 끝에서 시작 방향으로 탐색
    in >> word5;
    std::cout << "word1 = " << word1 << '\n'
              << "word2 = " << word2 << '\n'
              << "word3 = " << word3 << '\n'
              << "word4 = " << word4 << '\n'
              << "word5 = " << word5 << '\n';
}

출력:

word1 = Hello,
word2 = Hello,
word3 = World!
word4 = World!
word5 = World!

참고 항목

입력 위치 표시자를 설정함
( std::basic_istream<CharT,Traits> 의 public member function)
출력 위치 표시자를 설정함
( std::basic_ostream<CharT,Traits> 의 public member function)
seekoff ( ) 를 호출함
( std::basic_streambuf<CharT,Traits> 의 public member function)