I am pretty new to C++ and that's why I need some help.
In Python I would do it this way:
myString = "test|arg" myArg = myString.split("|")[0] But now I am in C++ and I am having a char and want to kinda remove a special part.
#include "stdafx.h" #include <iostream> #include <boost/algorithm/string.hpp> bool isPartOf(const std::string& word, const std::string& sentence) { return sentence.find(word) != std::string::npos; } int _tmain(int argc, _TCHAR* argv[]) { char* myChar= "test|me"; if (isPartOf("|me", myChar)) { std::string sStr(myChar); boost::replace_all(sStr, "|me", ""); std::copy(sStr.begin(), sStr.end(), myChar); myChar[sStr.size()] = '\0'; printf(myChar); system("pause>nul"); } } That's my current code but I get this error:
Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that >may be unsafe - this call relies on the caller to check that the passed values >are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See >documentation on how to use Visual C++ 'Checked Iterators' c:\program files >(x86)\vc\include\xutility 2132 1 ConsoleApplication2
I hope someone could help me
Best regards
std::stringinstead of achar*