I've the following code, where.
s[] - generates a char array and
longStr - is a cons char*. I want to combine these 2 into a single const char* such that s should be added first followed by longStr. something like below:
const char* combinedStr = ADD s[] and then longStr;
The size of longStr can keep changing. Hence, allocating the combinedStr statically wouldn't be a good utilization of memory. Is there a way to d o it dynamically without allocating the size statically for the combinedStr( also without using VLA).
Code
void concatenate(const char* longStr)
{
time_t t = time(NULL);
struct tm timeinfo;
localtime_s(&timeinfo, &t);
char s[100];
strftime(s, sizeof(s), "%c", &timeinfo);
//NOW I WANT TO Combine "s[]" & longStr in such a way that s should be added 1st followed by longStr.
const char* combinedStr = ADD s[] and then longStr;
}