Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

How to read the contents of any array that contains text

#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