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;
参数
_Next
输出迭代器要插入的位置表示时间和日期的字符序列。_Iosbase
未使用。_Fill
为了节省空间使用的类型 CharType 字符。_Pt
是时间和日期的信息输出。_Fmt
输出的格式。 为有效值参见 strftime, wcsftime, _strftime_l, _wcsftime_l。_Mod
格式的一个修饰符。 为有效值参见 strftime, wcsftime, _strftime_l, _wcsftime_l。_First
格式字符串的开头的输出。 为有效值参见 strftime, wcsftime, _strftime_l, _wcsftime_l。_Last
格式字符串的末尾输出。 为有效值参见 strftime, wcsftime, _strftime_l, _wcsftime_l。
返回值
对于第一个位置的迭代器在插入的最后一个元素之后。
备注
第一个成员函数返回 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