I'm trying to add two strings with snprintf but apparently i dont know what i'm doing.
Here is the code block:
char * filename = NULL;
(void)snprintf (filename, sizeof(filename), "%s/%s",
PATH, FILE);
I also tried:
char * filename = NULL;
(void)snprintf (filename, sizeof(PATH)+sizeof(FILE)+1, "%s/%s",
PATH, FILE);
PATH and FILE are header defined strings. Occassionally, this code works, occassionally it does not. I'm sure it's some kind of memory issue, what have I done wrong?
EDIT: My issue was for some reason thinking that snprintf allocated memory for you. I'm accepting the answer that cleared that up, since it was my real issue, but I've decided to go with the compile time string concatenation since that is a really nice trick.