#include <iostream>

#include <string>

using namespace std;


int main()

{

    string teststring;


    teststring = "asdf asdf asdf";


    int spacePos = 0;

    while (spacePos != -1)

    {

        spacePos = teststring.find(" ", spacePos+3);

        string str = "\n";

        teststring.replace(spacePos, 1, str);

    }


    cout << teststring;

    return 0;

}


teststring에서 띄어쓰기를 전부 줄바꿈으로 대체시키는 코드인데

while문 끝나는지점에서 예외가 처리되지않음이라 뜨는데 뭐때문에 그런지 도무지 모르겠습니다...ㅠㅠ 


아래는 디버깅 하면 나오는 화면입니다.