문자열이 있습니다. 문자열에 "Hello \ nThis is a test. \ n"가 포함되어 있습니다.char가 새 줄과 같은지 확인하는 방법
문자열의 모든 \ n에 전체 문자열을 분할하고 싶습니다. 나는 이미이 코드를 만든 :
vector<string> inData = "Hello\nThis is a test.\n";
for (int i = 0; i < (int)inData.length(); i++)
{
if(inData.at(i) == "\n")
{
}
}
을하지만이 complite 때, 다음 오류가 발생합니다 : (\ n은 문자열로)
'==' : no conversion from 'const char *' to 'int'
'==' : 'int' differs in levels of indirection from 'const char [2]'
(코드 위)
binary '==' : no operator found which takes a left-hand operand of type 'char' (or there is no acceptable conversion)
문제는 char가 "new line"과 같은지 확인할 수 없다는 것입니다. 어떻게해야합니까?
'벡터'이라는 것이 확실합니까? –