I have the following code:
typedef struct
{
string name;
int length;
}myStruct;
static myStruct getname()
{
static myStruct name;
if (name.length == 0)
{
name.value = "BLABLA";
name.length = name.value.size();
}
return &name;
}
Is this code safe?? i.e can I guarantee that after constructing myStruct name
, name.length
will be equal to 0