I keep getting an error telling me that I am not defining buffer in the scope under the if(!buffer.empty) loop.
Does anyone have any advice on what I should do and what I'm doing wrong?
#include <fstream>  // this is to import the ifstream and ofstream objects
#include <iostream>  // this is to import the cin and cout objects
#include <stack> 
using namespace std;
// precondition: theFile refers to a stream that has been opened already
// postcondition: the contents of the file have been read and output to the console
void read_file( ifstream& theFile ) {
    stack buffer;  // this string will read in the buffer from the file 
    //while there are still things in the file to read in, read it in and output to console.
    while( theFile.eof() == false ) {
        buffer.push(theFile);
        //cout << buffer << endl; // print the string and a newline 
    }
    if( !buffer.empty() ) {
        cout << buffer.top() << endl;
        buffer.pop();
    }else{
        cout << "uh oh!" << endl;
    }
}
int main() {
    ifstream theInputFile;
    theInputFile.open("input.txt"); // Open the file with the name "inputFile.txt". 
    // pass the file stream into the read_file() function. 
    read_file( theInputFile );
    theInputFile.close();
}
 
     
    