I was implementing a C function to do manipulations of strings.
At the end I had to return pointer to static string but before that the first element of the string had to be set to '\0'
char *funct(...)
{
static char string[30];
.
. //do some manipulations and possibly return here
.
string[0] = '\0';
return string;
}
Everything works absolutely fine to this point, but then I wanted to merge the last two lines :
char *funct(...)
{
static char string[30];
.
. //do some manipulations and possibly return here
.
return &(string[0] = '\0');
}
Then I got the error "lvalue required as unary ‘&’ operand". I presume that's so because the compiler threats everithing within the brackets as a number, not a variable and as we all know you can't have address of just a number ( "return &('\0');" is wrong).
My question is absolutely inessential but still I'm eager to know if you can trick the compiler(gcc in my case) to treat the content in the brackets as a variable and not a number
Thanks in advance :)