time_put::put

输出时间和日期信息为 CharType。. 序列。

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) 的所有元素。一个百分比 (%) 以外。 对于位于 [_First 的 C,_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;
}
  

要求

页眉: <区域设置>

命名空间: std

请参见

参考

time_put 类