creating global constant using strcat

I need to have some global constants that represent directory paths. In this way some constants are actually built by concatenating other constants. I have therefore tried to use strcat function but it fails.

What I am trying to do looks like this:
#include <iostream>
#include <string>

const char str1[] = "ABC";
const char str2[] = "DEF";
const char str3[] = strcat(str3, str1);

The strcat does not compile. What is the solution to this problem?
It's easy if you use std::string.

1
2
3
const std::string str1 = "ABC";
const std::string str2 = "DEF";
const std::string str3 = str3 + str1;
For starters:
str3[] = strcat(str3, str1);
is undefined, because you try to initialize str3 with itself. I expect you intended to use str2 instead of str3.

Second, str3 doesn't need to be a global value, you could just concatenate str1 and str2 whenever you need str3.
Topic archived. No new replies allowed.