How do I properly turn a const char* returned from a function into a const char** in C?
Posted
by spirulence
on Stack Overflow
See other posts from Stack Overflow
or by spirulence
Published on 2010-05-09T04:23:03Z
Indexed on
2010/05/09
4:28 UTC
Read the original article
Hit count: 214
In short, I would like to do this:
const char **stringPtr = &getString();
However, I understand that you can't & on rvalues. So I'm stuck with this:
const char *string = getString();
const char **stringPtr = &string;
I can live with two lines. Am I introducing problems with this hack? I should have no fear of passing stringPtr out of the function it is declared in, right?
© Stack Overflow or respective owner