   char buffers, pointers and LPCSTR's
  Hey, first I'll tell you what I'm trying to do, I currently have 2 strings in the form LPCSTR that I wish to concatenate, obviously you can't simply say that one LPCSTR = another as it's a pointer and even dereferenceing it wouldn't work seeing as it's a constant string, so what I am trying to do is this effectively[source lang ="cpp"]char* cPath = "Media/LightProbes/";LPCSTR stringBuffer;char cBuffer[256];std::vector<LPCSTR> vCubeMapDirectories;for(UINT i = 0; i < Directories.size(); ++i){sprintf_s(Buffer, "%s%s", cPath, Directories);stringBuffer = LPCSTR(Buffer);vCubeMapDirectories.push_back(stringBuffer);}What this is supposed to do is add "Media/LightProbes/" with whatever is in the LPCSTR vector Directories (contains the file name) at whatever iteration we are at. The problem is that I think you need to create a new buffer everything time you call sprintf_s, what is currently happening is it is just filling the vCubeMapDirectories vector with the last object in Directories, for example if the last object in Directories was "Beach.dds", I would have a vector the same size as Directories, but every member would say "Media/LightProbes/Beach.dds", I know that every LPCSTR in Directories is unique as I have manually checked them all, I've been trying to figure this out for a few days now, and thought I'd seek help, thanks.   
  You are using std::vector, so use std::string. Yes, for a process like this you would have to reallocate new buffers and no, you don't want to manage that yourself if you don't have to. You can just call c_str() on a std::string when you need a const char* or a const LPCSTR (they are the same thing BTW - LPCSTR is Windows-ese for "long pointer to const string", the "long" is now redundant since we moved to 32 bit and a const string in this context is a const char array):std::string cPath = "Media/LightProbes/";std::vector<std::string> vCubeMapDirectories;for(UINT i = 0; i < Directories.size(); ++i){   std::string s=cPath+Directories;vCubeMapDirectories.push_back(s);}void f(){    An_API_Call_That_Takes_const_LPCSTR(vCubeMapDirectories[0].c_str());}If you need to deal with an API call that requires a mutable (i.e. non-const) character array, let us know as there are ways to achieve that too.   ;  Why mess with LPCSTR at all? You are storing pointers to a temporary, this is a problem, a problem that std::string solves while simultaneously simplifying the program:std::string Path = "Media/LightProbes/";std::vector<std::string> CubeMapDirectories;for(int i = 0; i < Directories.size(); ++i){CubeMapDirectories.push_back(Path + Directories);};  I'd change the type of vCubeMapDirectories to std::string, so:[source lang ="cpp"]char* cPath = "Media/LightProbes/";std::string stringBuffer;char cBuffer[256];std::vector<std::string> vCubeMapDirectories;for(UINT i = 0; i < Directories.size(); ++i){   stringBuffer = cPathM   stringBuffer.append (Directories);vCubeMapDirectories.push_back(stringBuffer);}This way you don't have to worry about creating a new buffer for each element, then freeing it. You also avoid having to worry about buffer size.   ;  I would just create a std::string with the path, you can pass in a LPCSTR to the constructor.  I would that concatinate the path you needed, then pass out the LPCSTR with the c_str method.theTroll   ;  Whoaaa!! You guys are fast.   ;  Hey, thanks for the replies. Ok I've changed it all to std:string was all have advised, although, I pass the vector to a function, and when I try to use this code to copy the strings to a vector of LPCSTR's (std::vector<LPCSTR> m_EnvironmentMapDirs), whith this code;for(UINT i = 0; i < vecCubeMapFilePaths.size(); i++){m_EnvironmentMapDirs.push_back(vecCubeMapFilePaths.c_str);}I get the followingerror C3867: 'std::basic_string<_Elem,_Traits,_Ax>::c_str': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Ax>::c_str' to create a pointer to member1>   with1>   [1>  _Elem=char,1>  _Traits=std::char_traits<char>,1>  _Ax=std::allocator<char>1>   ];  c_str is a function, thus you need parens: .c_str()   ;Quote:Original post by leet bixerror C3867: 'std::basic_string<_Elem,_Traits,_Ax>::c_str': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Ax>::c_str' to create a pointer to member1>   with1>   [1>  _Elem=char,1>  _Traits=std::char_traits<char>,1>  _Ax=std::allocator<char>1>   ]I've got nothing to do for 5 minutes while I wait for our game to launch, so it's time for a lesson in reading template error messages (yay)! In this case, the error is very helpful, but it can definitely look like a bunch of jumbled nonsense if we don't know what we're looking for. Lets start with the first bit:Quote:error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::c_str':The first part is easy enough: we have an error [grin]. std::basic_string<_Elem,_Traits,_Ax> tells us that this error involves std::basic_string, which is a template class that takes three template args: _Elem, _Traits, and _Ax. A bit of googling or MSDNing will show us that std::string is, in fact, a typedef of std::basic_string<char>, using the default args for _Traits and _Ax. So, our error is really:Quote:error C3867: 'std::string::c_str':Which looks an awful lot like a member function to me.So far so good, now for the next bit:Quote:function call missing argument list;From above, we know that this error has to do with the c_str member function of std::string. Look like we forgot to give it an argument list.Quote:use '&std::basic_string<_Elem,_Traits,_Ax>::c_str' to create a pointer to memberEither that, or we were trying to create a pointer to the member function std::string::c_str. If we want to do that, looks like we need to use operator&.Finally, we have this:Quote:1>   with1>   [1>  _Elem=char,1>  _Traits=std::char_traits<char>,1>  _Ax=std::allocator<char>1>   ]For this bit, we need to remember from above that std::string is really a typedef for std::basic_string<_Elem,_Traits,_Ax>. This tells us that for this particular case, we have a std::basic_string which was created with the template args: std::basic_string<char, std::char_triats<char>, std::allocator<char> >. Neat, but not all that useful in this case.   ;  Awesome guys thanks for all your help, and cheers for the info Driv3MeFar, I never knew what all that actually ment till now :) thanks heaps!   