How can I change the value or a static char* from a function? C++
- by flyout
I am trying to change the value of a "static char *" I define at startup, I do it from inside a function, and when this function returns the var I am trying to re-set the value doesn't retain it.
Example:
static char *X = "test_1";
void testFunc()
{
char buf[256];
// fill buf with stuff...
X = buf;
}
How can I achieve this without using static for buf? Should I use another datatype? if so, which one?