Extracts characters and stores them in an array.
streamsize readsome
(charT_type* s, streamsize n);
The function readsome extracts and stores characters in the buffer pointed to by s until the following conditions are met.
The number of characters extracted.
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