-1
比方說,我有一個數組將字符串數組放入參數中,然後將元素與文字字符串錯誤進行比較?
string test = {"test1, "test2"}
我有我的功能
void testing(string test){
for(int i = 0; i < 2; i++){
if(test[i] == "test1"){
cout << "success" << endl;
}
}
}
但是,當我編譯此,我得到一個錯誤......這是爲什麼? 有沒有不同的方法?
'字符串測試'看起來不像一個數組。它看起來像'string'。 – juanchopanza
'string test'中缺少''''test1'。 – shruti1810