Click to See Complete Forum and Search --> : BSTR


makina
May 18th, 1999, 04:59 PM
I need to how I can create a string which cat' various data to gether and then pass the variable to a BSTR.
e.g.
BSTR name= Information;
LPSTR test=information;
int i=10
sprintf(test,"the value is %i",i);

BSTR=SysAllocString(test);

This does not work. How can I make it work?

Bob Clarke
May 19th, 1999, 05:34 AM
Here's one way:

#include "afxpriv.h"

LPSTR information = "The value is ";
int i = 10;
CString test(information);
char pIToA[4];
itoa( i, pIToA, 10);
test += pIToA;
USES_CONVERSION;
BSTR Information = A2BSTR( test.GetBuffer(2));