Hi Guys,
I am writing a program that displays entires from an LDAP directory.
But, for the life of me, I can't put the text returned into a simple string variable.
[source]ppValue = ldap_get_values(pLdap,pEntry,pAttribute);
iValue = ldap_count_values(ppValue);
if(iValue)
{
std::cout<<ppValue[0]<<"\t";
//std::strcpy(szPath,ppValue[0]); // This wont compile <<<<<<
}[/source]
So, the std::cout displays happily. But I cant work out how to store this into a string (or char) variable.
error C2664: 'strcpy' : cannot convert parameter 1 from 'std::string' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Any help would be greatly appreciated.
Poblems copying a string of text
You don't need to use strcpy on std::strings. Just use the = operator:
[edit] Ninja'd!
const char* foo = "test";
std::string bar;
bar = foo;
std::cout << bar << std::endl;
[edit] Ninja'd!
Thanks guys.
I now have this;
But this produces this error;
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
I now have this;
iValue = ldap_count_values(ppValue);
if(iValue)
{
std::cout<<ppValue[0]<<"\t";
szPath=ppValue[0];
std::cout<<szPath<<std::endl;
}
But this produces this error;
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement