Good day all - this is my first post.
I've recently started to learn C and I love to be so close to the hardware. However, I have a question about char *. Does the following code cause a memory leak? I'm almost sure it does and sends shivers down the spine of any respectable c-programmer! :-)
What is the best way to do what I'm trying to achieve? I'm thinking of defining a char-array and passsing the address of tha to the doSomeSillyThing function.
Code:
int doSomeSillyThing(char **msg)
{
*msg = "Are you sure this is not causing a memory leak?"
return 10;
}
int main()
{
char **msg;
int code = doSomeSillyThing(msg);
}
Thanks for the help...