I need to pushback/ append another couple of strings with a given trailing pattern to an existing char array in C. To achieve that, i'm willing to use 'sprintf' as follows.
#include <stdio.h>
#include<string.h>
int main()
{
char my_str[1024]; // fixed length checked
char *s1 = "abcd", *s2 = "pqrs";
sprintf(my_str, "Hello World"); // begin part added
sprintf(my_str, "%s , push back '%s' and '%s'.", my_str, s1, s2); // adding more to end of "my_str" (with given trailling format)
/* here we always use 'my_str' as the first for the string format in sprintf - format starts with it */
return 0;
}
I receive "memory overlapping" warning when i follow this method. is it be a serious issue? (like a memory leak, wrong output, etc.)
strcatinstead.sprintf().