How can I concatenate the following char
and TCHAR
variables in C++?
TCHAR fileName[50];
TCHAR prefix[5] = "file_";
TCHAR ext[4] = ".csv";
char *id[10];
generateId(*id);
The generateId(char *s)
function simply generates a random string.
I need to end up with fileName
being something like file_randomIdGoesHere.csv
I have tried strncat(fileName, prefix, 5);
which works fine with all TCHAR
variables but not with char *
as it requires a const char *
instead, so maybe there's a better way of doing it, not sure how to convert char *
or char **
to const char *
.
Any ideas?
The error I get with strncat(fileName, id, 10)
is error: cannot convert 'char**' to 'const char*'