I have a function that declares an array of chars and then assigns a value to it and then the decayed pointer is passed to another func like this pseudo c code, so that if I do printf("country %s," country)
inside anotherfunc
it gives me "GERMANY"
void somefunc()
{
...
char *country = NULL;
country = "GERMANY"
...
anotherfunc(country); //printf("country %s," country)` == GERMANY
}
How do I move the call to anotherfunc outside of somefunc and still be able to pass the country char array? Right now, printf("country %s," country)
is giving me (null)
char *country = NULL; // declare country outside both somefunc and anotherfunc
somefunc(country); //"GERMANY" is assigned inside somefunc
//if I do `printf("country %s," country)` it is `(null)`
//so "GERMANY" is not available inside another func
anotherfunc(country);