Concatenate chars and std::strings.
I have an std::string variable called filename, then a const char* name as a parameter of a function, a char* directory and then I also want to add the string "\testing\", how can I concatenate directory + "\testing\" + name?
I was doing filename = *directory + "/textures/" + *name; but it the value of filename remains "".
Thanks in advance.
BTW, I'm using MSVS 2003 with it's implementation of STL.
filename = directory + string("textures") + string(name);
Note that the first cast to string is optional as the compiler will detect that it needs to cast to string itself. The second and subsequent (unless you interleave real strings) will need the explicit cast.
Free code: http://sol-biotech.com/code/.
It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up
The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw
God... I'm such a retard sometimes... Thanks mitakeet.