void createList () {
std::cout << "Enter a file Name, Example - example.txt\n" ;
std::string fileName ;
std::cin >> fileName; // leaves the new line in the input buffer
std::cin.ignore( 1000, '\n' ) ; // extract and discard the new line
std::ofstream myfile(fileName);
if( myfile.is_open() ) {
bool userDone = false ;
std::string listItem ;
while( !userDone &&
std::cout << "Enter a list item > " &&
std::getline( std::cin, listItem) ) {
myfile << listItem << '\n' ;
char yn ;
std::cout << "Are you done (y or n)? ";
std::cin >> yn; // leaves the new line in the input buffer
std::cin.ignore( 1000, '\n' ) ; // extract and discard the new line
userDone = ( yn == 'y' ) || ( yn == 'Y' ) ; // true if y was entered
}
}
else { // myfile.is_open() == false
std::cerr << "could not open file '" << fileName << "' for writing\n" ;
}
}