I have three char arrays. Each of them represents one part of a big file name I would like to have in the end.
For that matter I want to concatenate these char arrays into one big array to pass it onto cImage.Save
as file name.
Here's what I got to build up the strings:
// Time
time_t rawtime = time(NULL);
struct tm timeInfo;
// Strings
char path[sizeof("G:\\screenify_images\\")] = { "G:\\screenify_images\\" };
char fileName[128] = { 0 };
char fileExtension[16] = { ".jpeg" };
// Get current time and save it as string
localtime_s(&timeInfo, &rawtime);
strftime(fileName, 128, "%X", &timeInfo);
cout << "Path:" << path << endl << "FileName:" << fileName << endl << "Extension:" << fileExtension << endl;
// Memory for our new, final string
char *fullPath = new char[strlen(path) + strlen(fileName) + strlen(fileExtension) + 1];
strcat_s(fullPath, 128, path);
strcat_s(fullPath, 128, fileName);
strcat_s(fullPath, 16, fileExtension);
Unfortunately it's either not working at all (not even throwing errors, just hanging up) or the full name has some weird chars in the beginning. I fear this has to do with me allocating memory not correctly or some other mistake.
Any help is welcome!