Hello All,
This is the code that does not work properly:
Code:
char dbszSQL[1024];
IString theStartDate("2004-01-01-00.00.00.000000"), theEndDate("2005-01-01-00.00.00.000000");
sprintf(dbszSQL, " hello %s AND %s ", theStartDate, theEndDate);
cout<< dbszSQL<< endl;
This is what gets printed on the screen:
hello ð%2È AND 2004-01-01-00.00.00.000000
This is what I expect:
hello Surinder 2004-01-01-00.00.00.000000 AND 2005-01-01-00.00.00.000000
After the sprintf executes I check the values for the two IString objects which look normal. My IString class is a wrapper around STL:string and I do have a conversion operator defined and this is what it looks like:
Code:
IString::operator char*() const
{
return (char *) buffer.data();
}
now buffer is the stl string object. Does anyone know what I might be missing?
Here is the debugger printout for startDate and endDate:
Code:
(dbx) p theEndDate
(buffer =
_String_base:)
_String_val<char,std::allocator<char> >:(_Alval = ))
(npos = 4294967295, _Ptr = "2005-01-01-00.00.00.000000", _Len = 26, _Res = 31))
(dbx) p theStartDate
(buffer =
_String_base:)
_String_val<char,std::allocator<char> >:(_Alval = ))
(npos = 4294967295, _Ptr = "2004-01-01-00.00.00.000000", _Len = 26, _Res = 31))