Namespaces
Variants

std:: ends

From cppreference.net
< cpp ‎ | io ‎ | manip
헤더 파일에 정의됨 <ostream>
template < class CharT, class Traits >
std:: basic_ostream < CharT, Traits > & ends ( std:: basic_ostream < CharT, Traits > & os ) ;

출력 시퀀스에 널 문자를 삽입합니다 os 마치 os. put ( CharT ( ) ) 를 호출하는 것처럼.

이것은 출력 전용 I/O 조정자이며, out << std :: ends 와 같은 표현식으로 호출될 수 있습니다. 여기서 out std::basic_ostream 타입의 객체입니다.

목차

참고 사항

이 매니퓰레이터는 일반적으로 std:: ostrstream 와 함께 사용되며, 연관된 출력 버퍼가 C 문자열로 처리되기 위해 null 종료되어야 할 때 필요합니다.

std::endl 과 달리, 이 매니퓰레이터는 스트림을 플러시하지 않습니다.

매개변수

os - 출력 스트림에 대한 참조

반환값

os (널 문자 삽입 후의 스트림에 대한 참조).

예제

#include <cstdio>
#include <strstream>
int main()
{
    std::ostrstream oss;
    oss << "Sample text: " << 42 << std::ends;
    std::printf("%s\n", oss.str());
    oss.freeze(false); // enable memory deallocation
}

출력:

Sample text: 42

참고 항목

(C++98에서 사용 중단됨) (C++26에서 제거됨)
문자 배열 출력 연산을 구현함
(클래스)