Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting char* to _bstr_t 1

Status
Not open for further replies.

frederic

Programmer
Nov 21, 2000
1
0
0
FR
could you please help me to convert a string such a char*
to a _bstr_t !!!!
Maybe a cast operation but which one ???

Thanks in advance
 
Dear frederic,

the ATL class _bstr_t has an assignment operator ( operator=(const char*) ) that takes a char* argument. The assignment operator throws a _com_error, so without error handling you just do this;

_bstr_t myBstr("hello world");
char* msg = "so long for now";
myBstr = msg;

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top