Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Poblems copying a string of text

This topic is 2454 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. :cool:

Share this post


Link to post
Share on other sites
Advertisement
You don't need to use strcpy on std::strings. Just use the = operator:

const char* foo = "test";
std::string bar;

bar = foo;
std::cout << bar << std::endl;




[edit] Ninja'd!

Share this post


Link to post
Share on other sites
Thanks guys.

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)



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!