| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
string to bstr
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?
|
|
#2
|
|||
|
|||
|
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; Code:
#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
}
if else let me know |
|
#3
|
|||
|
|||
|
Put that data into CString and then use AllovSysString to put it into BSTR.
Isn't that simple ................. |
|
#4
|
|||
|
|||
|
Re: string to bstr
thanks, both are true. additionally i have forgatton to add MFC and ATL support to my project
have a nice day |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|