On Fri, Apr 30, 2004 at 06:12:35AM -0700, Tony Reina wrote:
> CString cmd, msg;
> cmd.Format("1\t\2\t{3,4,5}\n");
> * PQputCopyData(conn, cmd, sizeof(cmd));
> cmd.Format("\\.\n");
> * PQputCopyData(conn, cmd, sizeof(cmd));
> * PQputCopyEnd(conn, msg);
> Old C++ code works, new stuff doesn't. Only line that have changed are
> *'d.
I'm not surprised. CString is clearly a class, and cmd is an object of
that class. Apparently that class has an implicit conversion operator to
char * (which is a striking example of a Bad Idea--kids, don't try this
at home!) but nonetheless, sizeof() should still give you the size of the
object, *not* the size of the string it represents!
You might try porting your code to libpqxx, which is C++-native and should
make large swathes of this sort of code unnecessary.
Jeroen