I am trying to use sscanf to separate a string that has a boost date. here’s the code:
std::sscanf(ss.c_str(),"%ls\t%lf\t%lf",&date1_,&num1_,&num2_);
and I get the following error:
warning: format ‘%ls’ expects type ‘wchar_t*’, but argument 3 has type ‘boost::gregorian::date*’
can anyone suggest me a fix for this. thx!
It cannot be done this way.
sscanfis a C function and can only read primitive types, not class types.In C++ the guns for reading/writing class types are “streams” and come in
<iostream>and<sstream>headers. They will work if the authors of the Boost library you’re using were kind enough to overloadoperator<<andoperator>>for this class.If the didn’t, then your best shot is to read the date fields (as basic types) one-by-one and then create a
boost::gregorian::dateobject using its constructor.