使用sscanf作为boost日期
using sscanf for boost date
我试图使用sscanf来分隔具有boost日期的字符串。下面是代码:
std::sscanf(ss.c_str(),"%lst%lft%lf",&date1_,&num1_,&num2_);
,得到以下错误:
warning: format ‘%ls’ expects type ‘wchar_t*’, but argument 3 has type ‘boost::gregorian::date*’
谁能建议我解决这个问题?谢谢!
不能这样做。sscanf
是一个C函数,只能读取基本类型,不能读取类类型。
在c++中,读写类类型的枪是"流",来自<iostream>
和<sstream>
头。如果您正在使用的Boost库的作者足够友好地为该类重载operator<<
和operator>>
,它们将工作。
如果没有,那么最好的方法是逐一读取日期字段(作为基本类型),然后使用其构造函数创建boost::gregorian::date
对象。
相关文章:
- BOOST :: Gregorian ::日期在内部存储日期
- 比较日期c++(使用boost)
- 对于C++中的日期/时间库,是否有一种轻量级的Boost替代方案
- 在QuantLib的日期类和C++11 / boost Chrno上
- Boost,如何将以下字符串解析为日期/时间
- 阅读和写作日期与boost
- boost截止日期计时器在iOS中过期不准确
- boost截止日期计时器我的代码不能同时运行
- 在C++/boost中将日期时间转换为不同的时区
- 如何解析带有日期-时间+时间偏移的字符串到boost::posix_time::ptime
- 夏令时和其他时区相关的问题与boost日期时间库
- 使用sscanf作为boost日期
- c++ boost regex日期错误
- boost:: posix_time.如何在同一个应用程序中表示微秒和纳秒日期时间
- 使用to_iso_extended_string与boost日期
- Boost 1.53本地日期时间编译器错误使用-std=c++0x
- Boost日期时间捕获异常
- boost日期时间--输出格式
- Visual Studio 2012中Boost posix日期和时间的编译错误
- 如何使用boost::date_time从time_t中获取本地日期时间