time_put::put

输出时间和日期信息作为 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;

参数

返回值

对于第一个位置的迭代器在插入的最后一个元素之后。

备注

第一个成员函数返回 do_put(_Next、_Iosbase、_Fill、_Pt、_Fmt,_Mod)。 第二个成员函数复制*_Next C++在[_First,_Last)的所有元素以及一百分号(%)之外,。 对于在 C 中的字符后跟一百分比 [_First,_Last),该函数计算 _Next = do_put(_Next、_Iosbase、_Fill、_Pt、C,0) 然后跳过 C。 但是,如果 C 是从设置的EOQ#的限定符,后跟在[_First,_Last)中的字符 C2,该函数计算 _Next = do_put(_Next、_Iosbase、_Fill、_Pt、C2、*C)*和跳过通过 C2。

示例

// 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;
}
  

要求

标头: <locale>

命名空间: std

请参见

参考

time_put Class