Search code examples
c++sqlstring-concatenation

_bstr_t concatenate gives 12142


I have a strange thing here. I'm concatenating _bstr_t strings in order to assemble a SQL command.

_bstr_t strSQL = a+b+k+hk+Allin+hk+k+hk  

...and so on.

When I print it to the console (using std::wcout << '/n'<< strSQL << '/n';) I get my string, BUT with a 12142 in the beginning and end of the string. It looks like:

 12142"SELECT * FROM....."12142

Does anyone know where it comes from?

I'm using: VS2010 Express, C++, and I'm building a console app.


Solution

  • You wrote '/n' instead of '\n'. This is a multicharacter literal, which in this case gives an integer with the value 12142.