I use the set_effect_block in the following code
to convert a string to a fixed size string of 20 bytes.
class editoritems{
public:
editoritems(string= "");
void set_effect_block(string paramnamestring) //set effect block
{
const char *effectnamevalue=paramnamestring.data();
int length=strlen(effectnamevalue);
length=(length<20?length:19);
strncpy_s(effe_block,effectnamevalue,length);
effe_block[length]='\0';
}
string get_effect_block()const{return effe_block;}
private:
char effe_block[20];
};
editoritems::editoritems(string h)
{
set_effect_block(h);
}
Is this a good way to do that ? Is there any faster way ?
strlento get the length of astd::string.