본문 바로가기

C++문법

string에서 앞 뒤 char 삭제하는 법

string word[50 + 1];

 

//앞의 anta 삭제
word[i] = word[i].substr(4, word[i].length());


//뒤의 tica 삭제
for (int j = 0; j < 4; ++j) {
word[i].pop_back();
}