basic_istream::readsome

Extracts characters and stores them in an array.

  streamsize readsome
     (charT_type* s, streamsize n);
  
Remarks

The function readsome extracts and stores characters in the buffer pointed to by s until the following conditions are met.

Return

The number of characters extracted.

Listing: Example of basic_istream::readsome() usage.
The file ewl-test contains:
CodeWarrior

Software at Work

Registered Trademark
  #include <iostream>
  #include <fstream>
  #include <sstream>
  #include <cstdlib>
  const short SIZE = 81;
  int main()
  {    
  using namespace std;
     ifstream in("ewl-test"); 
     if(!in.is_open()) 
     {cout << "can't open file for input"; exit(1);}
      char Buffer[SIZE] = "\0";
      ostringstream Paragraph;
       while(in.good() && (in.peek() != EOF))
     {
        in.readsome(Buffer, 5);   
        Paragraph << Buffer;
      }
     cout << Paragraph.str();
       in.close();
     return 0;
  }
  

Result:

  CodeWarrior
  Software at Work
  Registered Trademark