문자열 배열이 있으므로 하위 문자열 (이 경우 쉼표 사이의 문자열)을 가져 와서 다른 문자열 배열에 넣어야합니다.문자열 배열에서 문자열 함수 (.substr) 사용
나는 strings[numberOfTapes]
로 선언, 그래서 쉼표를 찾고 있어요 때 나는과 같이, 루프 중첩에 문자로 문자를 이동합니다
for(int j = 0; j < tapes[i].length(); j++){
if(tapes[i][j] == ','){
input[counter2] = tapes[i][j].substr(i-counter, counter);
}
}
하는 다음과 같은 에러가 발생
을request for member 'substr' in tapes[i].std::basic_string::operator[] [with _CharT = char, _Traits = std::char_traits, _Alloc = std::allocated] (((long unsigned int)))', which is of non class type 'char'
문자를 통해 문자를 j
으로 보내고 있습니다. .substr
이 tapes[i][j]
형식으로 작동하도록 할 수있는 방법이 있습니까? 아니면이 방법을 다르게 구현해야합니까?