I have got a real problem getting this function to work and do not really understand why.
Now what happens is, that no matter what value strFilePath1.length() returns, strlen(buffer) always is 25.Code:int CopyFiles(const std::string &strFilePath1, const std::string &strTargetPath, std::vector<std::string> &vecFilesCopied) { char *buffer = new char[strFilePath1.length()]; int StringPos, Test, Counter; Test = _snprintf(buffer, strFilePath1.length(), strFilePath1.c_str()); // blabla du some fancy stuff not causing any problems char *cTargetPath = new char[((strFilePath1.length()-StringPos) + strTargetPath.length())]; Test = _snprintf(cTargetPath, strTargetPath.length(), strTargetPath.c_str()); delete [] cTargetPath; delete [] buffer; return 0; }
The other problem I'm suffering from is, that I get a debug error when trying to delete both pointers.
Can anybody help me with this problem? Thank you very much in advance




Reply With Quote