-1
I’m using the function strcat() to concatenate string and I’m having trouble returning the string to the previous state, what I’ve tried so far is this, but with nothing successful:
const char *get_route(const char *route)
{
const char *final_str = strcat("https://discord.com/api/v9", route);
return final_str;
}
I take the string that comes in the parameter route, as an example /users/@me and concateno with the discord_api_url, take for example https://discord.com/api/v9/users/@me, but when I use the function again, the new value that comes from route is not concatenated with the variable discord_api_url and yes with the previous one that was https://discord.com/api/v9/users/@me, I’ve tried to use malloc() in a new string and copy the https://discord.com/api/v9 for her, but when I give a free() the string goes away :p
How do I after concatenation, the URL string is not modified and I can reuse this function again?