<p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">아래 코드는 파일에 쓰여있는 Customer라는 글자를 Admin이라는 글자로 바꾸는 코드입니다.</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">끝이 NULL로 잘 처리가 안 된것인지 Admin이 아니라 기존의 텍스트(Customer)와 겹쳐서 Adminmer가 되어버립니다.</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">Customer의 글자수가 더 많기 때문에 Admin에서 Customer로 바뀌는데는 지장이 없습니다.</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">바꾸기 전의 글자수가 바꾸고 싶은 글자수보다 이처럼 적은 경우는 문자의 뒷 부분이 기존 글씨와 글씨가 겹치는데 어떻게 해야할까요?</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">NULL을 제대로 삽입을 해야할 거 같긴한데.. 어찌해야할지 모르겠네요.</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><font size="2">(Admin + 띄어쓰기가 아니라 딱 Admin까지만 나오게 하고 싶습니다.)</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"><br></p> <p class="p1"><font size="3"> fstream fs;</font></p> <p class="p1"><font size="3"> fs.open(getLoginedID() + ".dat", /*fstream::binary |*/ fstream::in | fstream::out);</font></p> <p class="p2"><font size="3"><br></font></p> <p class="p1"><font size="3"> string str((istreambuf_iterator<char>(fs)), istreambuf_iterator<char>());</font></p> <p class="p1"><font size="3"> size_t pos = str.find("Customer");</font></p> <p class="p2"><font size="3"><br></font></p> <p class="p1"><font size="3"> if (pos != string::npos) {</font></p> <p class="p1"><font size="3"> cout << "string found at position: " << int(pos) << endl;</font></p> <p class="p1"><font size="3"> fs.seekp(pos);</font></p> <p class="p1"><font size="3"> fs << "\nAdmin"; </font></p> <p class="p1"><font size="3"> fs.put('\0');</font></p> <p class="p1"><font size="3"> //fs.write("\nAdmin\0", 7); <span class="s1">이</span> <span class="s1">방법으로도</span> <span class="s1">되지</span> <span class="s1">않음</span></font></p> <p class="p1"><font size="3"> }</font></p> <p class="p1"><font size="3"> fs.close();</font></p> <p class="pre" style="margin:0px 0px 18px;font-family:verdana, Arial, '맑은 고딕', 'malgun gothic', '돋움', Dotum, sans-serif;line-height:24px;"> </p> <p class="p1"><font size="3">}</font></p>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.