怎样改变ifstream读缓冲区的大小?我想设的大一些,不知道缺省大小是多大?

解决方案 »

  1.   

    ifstream( filedesc fd, char* pch, int nLength );nLength不就是指定读取的长度吗

    void copy_stream( std::ostream & out, std::istream & in)
    {
        char strBuffer[ 512];
        while ( in.read( strBuffer, 512) )
        {
            int nCount = in.gcount();
            out.write( strBuffer, nCount);
        }
    } 缺省是多大这个不知道
      

  2.   

    我用setbuf时编译不过:
    error C2039: 'setbuf' : is not a member of 'basic_ifstream<char,struct std::char_traits<char> >'
      

  3.   

    ifstream( filedesc fd, char* pch, int nLength );nLength就是指定读取的长度吗
      

  4.   

    我是这样用的
    ifstream in(fname);
    if(!in) return;
    char *rdbuf = new char[64000];
    in.setbuf(rdbuf, 64000);
    ...
    in.setbuf(NULL,0);
    delete [] rdbuf;
    return;