Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::setfill

      From cppreference.com
      <cpp‎ |io‎ |manip
       
       
       
      Input/output manipulators
      Floating-point formatting
      Integer formatting
      Boolean formatting
      Field width and fill control
      setfill
      Other formatting
      Whitespace processing
      Output flushing
      Status flags manipulation
      Time and money I/O
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Quoted manipulator
      (C++14)
       
      Defined in header<iomanip>
      template<class CharT>
      /*unspecified*/ setfill( CharT c);

      When used in an expressionout<< setfill(c) sets the fill character of the streamout toc.

      Contents

      [edit]Parameters

      c - new value for the fill character

      [edit]Return value

      An object of unspecified type such that

      • ifout is an object of typestd::basic_ostream<CharT, Traits>, the expressionout<< setfill(c)

      where the functionf is defined as:

      template<class CharT,class Traits>void f(std::basic_ios<CharT, Traits>& str, CharT c){// set fill character    str.fill(c);}

      [edit]Notes

      The current fill character may be obtained withstd::ostream::fill.

      [edit]Example

      Run this code
      #include <iomanip>#include <iostream> int main(){std::cout<<"default fill: ["<<std::setw(10)<<42<<"]\n"<<"setfill('*'): ["<< std::setfill('*')<<std::setw(10)<<42<<"]\n";}

      Output:

      default fill: [        42]setfill('*'): [********42]

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 183C++98setbase could only be used with
      streams of typestd::ostream
      usable with any output
      character stream

      [edit]See also

      manages the fill character
      (public member function ofstd::basic_ios<CharT,Traits>)[edit]
      sets the placement of fill characters
      (function)[edit]
      changes the width of the next input/output field
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/manip/setfill&oldid=159183"

      [8]ページ先頭

      ©2009-2025 Movatter.jp