#include #include // <--- NEW, this is needed for file i/o // fstream stands for file stream #include #include /* File I/O Program input - reading from a file output - writing to a file */ int main() { ifstream infile; // create a variable called infile // this is the file we will READ from ofstream outfile; // create a variable called outfile // this is the file we will WRITE to char word[100]; // this will hold a word to read or write outfile.open("j:\\myfile.txt", ios::out); // we are writing OUT do { cout << "Type in a word: "; cin.getline(word, 100); outfile << word << endl; }while(strcmp(word, "") != 0); outfile.close(); infile.open("j:\\carman_cpp\\carman\\myfile.txt", ios::in); // open file while(!infile.eof()) // eof - end of file { //infile >> word; // read in from file infile.getline(word, 100); cout << word << endl; } infile.close(); // close file return 0; }