std:: rewind
From cppreference.net
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)
|
C-style I/O
| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더 파일에 정의됨
<cstdio>
|
||
|
void
rewind
(
std::
FILE
*
stream
)
;
|
||
주어진 파일 스트림의 파일 위치 표시자를 시작 부분으로 이동합니다.
이 함수는 std:: fseek ( stream, 0 , SEEK_SET ) ; 와 동등하지만, 파일 끝 및 오류 표시자가 지워진다는 점이 다릅니다.
이 함수는 이전 호출에서 ungetc 를 통해 적용된 모든 효과를 제거합니다.
목차 |
매개변수
| stream | - | 수정할 파일 스트림 |
반환값
(없음)
예제
이 코드 실행
#include <array> #include <cstdio> int main() { std::FILE* f = std::fopen("file.txt", "w"); for (char ch = '0'; ch <= '9'; ch++) std::fputc(ch, f); std::fclose(f); std::array<char, 20> str; std::FILE* f2 = std::fopen("file.txt", "r"); const unsigned size1 = std::fread(str.data(), 1, str.size(), f2); std::puts(str.data()); std::printf("size1 = %u\n", size1); std::rewind(f2); const unsigned size2 = std::fread(str.data(), 1, str.size(), f2); std::puts(str.data()); std::printf("size2 = %u", size2); std::fclose(f2); }
출력:
0123456789 size1 = 10 0123456789 size2 = 10
참고 항목
|
파일 위치 표시자를 파일 내 특정 위치로 이동시킵니다
(함수) |
|
|
C documentation
for
rewind
|
|