I have const char* FilePathName which looks like this: C:\ImportantFile.hex
And an int id = 12345;
I need to define a new const char* FilePathName_ID that would append the id with an underscore to the original FilePathName to look like this: C:\ImportantFile_12345.hex
I have looked at this but its different as I am using const char* which gives me the error cannot convert from 'const char * ' to 'char'and need an underscore.
I need to end up with a const char*
EDIT I need to keep the file extension.
I have const char* FilePathName which looks like this: C:\ImportantFile.hex And an int id
Share
You need to create a new
std::stringobject or a null-terminated byte string. One easy way is this:You can pass a string literal to the above function seamlessly.
Update: I notice that you probably also need to strip the extension:
See updated definition of
append_number.Update 2: Try the following program:
The output should be: