How to convert const char * to CComBSTR ?

Hello everybody . I have two string . I want to compare them . But when i build , i get error , can not convert const char * to CComBSTR
this is my code
1
2
3
4
5
6
7
CComBSTR string1;
String string2=string1;
if(strcmp("http://abc@gmail.com",(const char*)string2) == 0) 
{										
	// do something
	printf ("OK");
}

Can you see it and fix them . Thank you .


A BSTR is a wide string. All the standard narrow/wide arguments conversion comments apply.

I have fix it as
1
2
3
4
5
6
7
CComBSTR string1;
BSTR string2=string1;
if(strcmp("http://abc@gmail.com",(const char*)string2) == 0) 
{										
	// do something
	printf ("OK");
}

And build it , get one errors
 
Error	1	error C2440: 'type cast' : cannot convert from 'ATL::BSTR' to 'const char *'
Last edited on
closed account (DSLq5Di1)
http://msdn.microsoft.com/en-us/library/d6x8shh5
http://msdn.microsoft.com/en-us/library/bdyd6xz6

1
2
3
4
5
6
CComBSTR string1;
if(string1 == L"http://abc@gmail.com") 
{										
	// do something
	printf ("OK");
}
oh thank kbw and sloppy9 . Problem is soluted .
Topic archived. No new replies allowed.