I Have a function that I cannot change like:
void f(char *var) {
var = (char*) malloc(size*sizeof(char)); // I dont know the size, its a example
// .. others operation with var
}
So whats the best way to initialize a variable using f
function:
char *myvar = "";
f(myvar);
// others operation;
free(myvar);
My question is it correct assign a const
as ""
to a char
pointer as myvar
? If not, how can I do it?