istream& read_word(istream&is,char* buffer,int max)
{
is.width(max);//read at most max-1 characters in the next>>
is>>buffer;//read whitespace-terminated word,add zero after the last character read into buffer
return is;
}
合理地设置独享istream的宽度能够避免>>操作导致缓冲区溢出