Udostępnij za pośrednictwem


time_put::put

Wyświetla datę i godzinę informacji jako sekwencja CharTypes.

iter_type put(
   iter_type _Next, 
   ios_base& _Iosbase,
   char_type _Fill, 
   const tm* _Pt, 
   char _Fmt, 
   char _Mod = 0
) const;
iter_type put(
   iter_type _Next, 
   ios_base& _Iosbase,
   char_type _Fill, 
   const tm* _Pt,
   const CharType* _First, 
   const CharType* _Last
) const;

Parametry

Wartość zwracana

Iterację pierwsze miejsce po ostatnim elementem wstawione.

Uwagi

The first member function returns do_put(_Next, _Iosbase, _Fill, _Pt, _Fmt, _Mod).Druga funkcja Członkowskie kopiuje *_Next ++ dowolnego elementu w interwale [_First, _Last) niż procentu (%).For a percent followed by a character C in the interval [_First, _Last), the function instead evaluates _Next = do_put(_Next, _Iosbase, _Fill, _Pt, C, 0) and skips past C.Jeśli jednak c jest znak z zestawu EOQ # następuje znak kwalifikatora C2 w interwale [_First, _Last), funkcja zamiast oblicza _Next = do_put(_Next, _Iosbase, _Fill, _Pt, C2, c) i pomija w przeszłości C2.

Przykład

// time_put_put.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <sstream>
#include <time.h>
using namespace std;
int main( )
{
   locale loc;
   basic_stringstream<char> pszPutI;
   ios_base::iostate st = 0;
   struct tm t;
   memset( &t, 0, sizeof( struct tm ) );

   t.tm_hour = 5;
   t.tm_min = 30;
   t.tm_sec = 40;
   t.tm_year = 00;
   t.tm_mday = 4;
   t.tm_mon = 6;

   pszPutI.imbue( loc );
   char *pattern = "x: %X %x";
   use_facet <time_put <char> >
   (loc).put(basic_ostream<char>::_Iter(pszPutI.rdbuf( )),
          pszPutI, ' ', &t, pattern, pattern+strlen(pattern));

      cout << "num_put( ) = " << pszPutI.rdbuf( )->str( ) << endl;

      char strftimebuf[255];
      strftime(&strftimebuf[0], 255, pattern, &t);
      cout << "strftime( ) = " << &strftimebuf[0] << endl;
}
  

Wymagania

Nagłówek: <locale>

Obszar nazw: std

Zobacz też

Informacje

time_put Class