我有这个代码不能正常工作.
for (int i = 0; i <= 140; i++)
{
if (OneLine_Array.GetAt(i) == "Pass" || "Fail" || "Warn" || "Active")
{
OneLine_State.Add(OneLine_Array.GetAt(i));
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有它,它将工作
for (int i = 0; i <= 140; i++)
{
if ((OneLine_Array.GetAt(i) == "Pass") || (OneLine_Array.GetAt(i) == "Fail") || (OneLine_Array.GetAt(i) == "Warn") || (OneLine_Array.GetAt(i) == "Active"))
{
OneLine_State.Add(OneLine_Array.GetAt(i));
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道有没有更短的方法来做这个而不是一遍又一遍地复制相同的代码行?
谢谢.
为了从给定路径获取父目录,我有以下代码。注:为size_t是一种类型定义为unsigned int类型。
/****************************************************
This function takes a full path to a file, and returns
the directory path by returning the string up to the last backslash.
Author: Aashish Bharadwaj
*****************************************************/
_TCHAR* GetDirectoryFromPath(const _TCHAR* path)
{
size_t size = _tcslen(path);
size_t lastBackslash = 0;
for (size_t i = 0; i < size; i++)
{
if (path[i] == '\\')
{
lastBackslash = i;
}
}
_TCHAR* dirPath = new _TCHAR();
size_t i;
for (i = 0; …Run Code Online (Sandbox Code Playgroud) 我有两个错误,让我生病,有点困惑.
错误#1:
错误C2679:二进制'+ =':找不到运算符,它接受类型'std :: basic_string <_Elem,_Traits,_Ax>'的右手操作数(或者没有可接受的转换)
此错误的代码是:
CString lancuch1;
lancuch1 = "Znaleziono ";
lancuch1 += liczba1.str();
lancuch1 += " pozycji.";
Run Code Online (Sandbox Code Playgroud)
而第二个,更奇怪:
错误#2:
错误C2440:'初始化':无法从'std :: _ Vector_iterator <_Ty,_Alloc>'转换为'std :: basic_string <_Elem,_Traits,_Ax>'
这个错误我有7次写入此代码:
for(int i = 0 ; i < pojemnosc_vectora; i++){
std::string linijka = (vector.begin()+i);
char deli = ';';
int a = 0;
for(int i = 0; i<5; i++){
std::string pokico = linijka.substr(a, deli);
vector2.push_back(pokico);
a+=pokico.length();
}
}
int licznik_komunikatow=0;
for(int i=0; i<vector.size(); i++){
std::string komunikat1 = vector2.begin()+(licznik_komunikatow);
std::string komunikat2 …Run Code Online (Sandbox Code Playgroud) 如何\从 CString 中删除此字符?
例如:我有这个内容的字符串“这是\一个字符串”
如何\从我的字符串中删除?
非常感谢。