istream에서 string객체 읽어오기
글쓴이: purewell / 작성시간: 금, 2005/12/09 - 4:58오후
istream& __getFromStream(string& str, istream& is) { char buf[1024*2]; const size_t maxlen(sizeof(buf)); ios_base::iostate istat(is.rdstate()); str.clear(); while(istat&ios_base::eofbit) { *buf=0x00; is.getline(buf, maxlen); str+=buf; istat = is.rdstate(); if (istat&ios_base::failbit) { is.clear(istat&~ios_base::failbit); continue; } if (istat&ios_base::goodbit) { break; } } return is; }
Forums:
댓글 달기