/***************************************************
Print town names from census data
***************************************************/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
// Open census data file
ifstream fin("tempdata");
// Read in (and ignore!) header information
// Loop over each row
while(fin)
{
/***** Process row **************/
// Read name of city/town/village
string t, N;
fin >> t;
if(!fin) break; // failure of (fin >> t) will cause fin to evaluate to false
while(t != "town" && t != "city" && t != "village")
{
N = N + t;
fin >> t;
}
// Print name if town
if (t == "town")
cout << N << endl;
// Read (and ignore) 12 entries
string s;
for(int i=0; i<12; i++)
fin >> s;
}
return 0;
}