/*
* @topic T00345 Apr 18 -- how to print HTML content withut tags v.3
* @brief Program uses <tt>std::cin()</tt> to read HTML input
*/
#include <iostream>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{
// This version of the program uses unformatted input
// from std::cin() to get HTML input.
bool flag_inside_tag = false;
// Use unformatted input to read HTML character-by-character:
int onechar; // using int because char cannot represent EOF
while ( ( onechar = cin.get() ) != EOF ) {
if ( onechar == '<') {
// Encountered opening of an HTML tag
flag_inside_tag = true;
continue;
}
if ( onechar == '>') {
// Encountered closing of an HTML tag
flag_inside_tag = false;
cout << " ";
continue;
}
if ( flag_inside_tag == false ) {
// Print everything outside of HTML tags
std::cout.put( onechar );
}
}
return 0;
}