Given this code:
void group::build(int size, std::string *ips){
/*Build the LL after receiving the
member list from bootstrap*/
head = new member("head");
member *temp1,*temp2;
temp1 = new member(ips[0].data()); // error here
// ....
}
member::member(char *ip){
strcpy_s(this->ip_addr,sizeof(ip),ip);
this->next = NULL;
this->previous = NULL;
}
And a pointer to string defined as:
std::string *ips;
I want to initialize the array, ips with strings but when I try to get the char data from any array member I get the error:
cannot convert parameter from
const char *tochar *
Why?
strcpy_sis wrong. Firstly, the second parameter is the size of the destination buffer, but you aren't providing that. Secondly,sizeof(ip)is the size of achar*in bytes, nothing to do with the length of the string.