streamsize  readsome (char* s, streamsize n );

Read a block of data.
  Reads a block of data with a size determined by the smaller between parameter n and the number of available characters in the stream before the end of its buffer.


Pointer to an array of characters to be read.
Integer value of type streamsize representing the maximum size of the block to be read.

Return Value.
  The function returns an integer value of type streamsize representing the number of characters successfully read.


// read a file with readsome.
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  int length;
  char block [100];

  ifstream is; ("test.txt", ios::binary );

  length = 0;
  while (is.good())
    length += is.readsome (block,100);
    cout.write (block,100);


  cout << "\nFile was " << length << " characters long";

  return 0;

Basic template member declaration ( basic_istream<charT,traits> ):
typedef charT char_type;
streamsize readsome ( char_type* s, streamsize n );

See also.
  read, get
  istream class

© The C++ Resources Network, 2001