How to read the contents of any array that contains text : istrstream « File Stream « C++ Tutorial






#include <iostream>
#include <strstream>
using namespace std;

int main()
{
  char s[] = "1.3 this is a test <<>><<?!\n";

  istrstream ins(s);

  char ch;

  ins.unsetf(ios::skipws); // don't skip spaces
  while (ins) { // false when end of array is reached
    ins >> ch;
    cout << ch;
  }

  return 0;
}
1.3 this is a test <<>><








12.17.istrstream
12.17.1.Attempt to read from empty stream
12.17.2.Demonstrating input from an istringstream object
12.17.3.Use istrstream to read int, float and char
12.17.4.How to read the contents of any array that contains text
12.17.5.Read and display binary data