c - returning address form a function -
i have returned address form function search(keys),
return ptr->keys[pos]
where ptr->keys[pos].value used access member function of keys. above return statement correct? return address after returns have done
struct classifier keys,temp,*temp_ptr; temp = search(key); temp_ptr = &temp;
and accessing member function value of keys as
temp->value
from you've said, if pos 0 or 1 it's valid index in keys , return statement is ostensibly correct. please post realistic code though: question's "struct classifier keys,..." not reconcilable "struct classifier keys[2]" mentioned in comment above. following code not correct: temp = search(key);
tries copy pointer structure. might mean temp = *search(key)
, copy struct classifier's content out. can use temp.value or temp_ptr->value not temp->value asked.
Comments
Post a Comment