In my function I want to return an empty string ""
, function looks like this:
char *myFunction(nodeType *arg){
if (something){
return anotherFunction(arg);
} else {
return EMPTYSTRING;
}
}
(EMPTYSTRING should be replaced with correct expression to return ""
)
Some ways I came up with:
return ""
return '\0'
What is the right way to return an empty string?
return
edNULL
in place ofEMPTYSTRING
– babon Oct 1 '17 at 17:59char *
and notconst char *
. Just something to be aware of.return ""
will give you read-only memory that shouldn't be freed. – Millie Smith Oct 1 '17 at 18:02