alptek
July 11th, 2005, 06:14 AM
hi, i get an input from user with "cin" command and i need to convert this to a "bstr". in fact i did it with "_bstr_" object but it gave error when buildinbg the project. does anyone have other alternatives?
|
Click to See Complete Forum and Search --> : string to bstr alptek July 11th, 2005, 06:14 AM hi, i get an input from user with "cin" command and i need to convert this to a "bstr". in fact i did it with "_bstr_" object but it gave error when buildinbg the project. does anyone have other alternatives? humptydumpty July 11th, 2005, 06:41 AM A BSTR, known as basic string or binary string, is a pointer to a wide character string used by Automation data manipulation functions. typedef OLECHAR FAR* BSTR; #include "stdafx.h" #include "afxwin.h" #include "iostream.h" #include "string.h" int main(int argc, char* argv[]) { BSTR bstr1 = NULL; char *str = new char[255]; cin>>str; bstr1 = (BSTR)str; char *ptr =(char*) bstr1; cout<<ptr; return 0; // and delete the pointer here } do you want this or something else. if else let me know pranavsharma July 11th, 2005, 07:04 AM Put that data into CString and then use AllovSysString to put it into BSTR. Isn't that simple ................. alptek July 11th, 2005, 09:46 AM thanks, both are true. additionally i have forgatton to add MFC and ATL support to my project have a nice day codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |