Hello All,
This is the code that does not work properly:
This is what gets printed on the screen: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;
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:
now buffer is the stl string object. Does anyone know what I might be missing?Code:IString::operator char*() const { return (char *) buffer.data(); }
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))



LinkBack URL
About LinkBacks



erator char* cost