int main()
{
char myString = NULL;
realloc(&myString, 5);
strncpy((char *)&myString, "test", 5);
}
Seems to work Fine but, i'm still slightly confused about stack vs heap, is this allowed? Does myString need to be freed manually or will it be released when it goes out of scope?
Edit: Thanks for the responses, so i presume this is equally illegal
//I want the code to change myString to "tests"
char myString[5] = "test";
realloc(&myString, strlen(myString)+2);
myString[4] = 's';
myString[5] = '\0';