#include <fstream> 
#include <iostream> 
#include <string> 
using namespace std; 
  
int main() 
{ 
  // read a student's name from the keyboard (see 5.1) 
  string name; 
  cout << "What is your name? "; 
  getline(cin, name); 
  
  // write the student's name to classRoster.txt 
  ofstream fout; 
  fout.open("classRoster.txt", ios::app); 
  if (!fout.good()) throw "I/O error"; 
  fout << name << endl; 
  fout.close(); 
} 
