1 #include <iostream> 2 #include <fstream> 3 #include <string> 4 using namespace std; 5 6 int main() 7 { 8 // Open a file 9 ifstream input("state.txt"); 10 11 if (input.fail()) 12 { 13 cout << "File does not exist" << endl; 14 cout << "Exit program" << endl; 15 return 0; 16 } 17 18 // Read data 19 string city; 20 21 while (!input.eof()) // Continue if not end of file 22 { 23 getline(input, city, '#'); 24 cout << city << endl; 25 } 26 27 input.close(); 28 29 cout << "Done" << endl; 30 31 return 0; 32 }