Hello everyone,
I'm trying to return a string to then call it on main function.

My code is the following :

Code:
const char* coiso(int chave){
    char str [50];
    sprintf(str,"%d",chave);
    char txt[50] = ".txt";
    strcat(str,txt);
    return str;
}


int main ()
{
    const char* info = coiso(8);
    printf("%s",info);
}
If I do a printf("%s",str) in coiso function it works but the following code doesn't work.

Any idea why ? :/

Thanks!