intstack.h cannot be changed

class IntStack

private:
   int *stackArray;  // Pointer to the dynamically allocated stack array
   int stackSize;    // The stack size
   int top;          // Indicates the top of the stack

public:
   // Constructor
   IntStack(int);

   // Destructor
   ~IntStack();

   // Stack operations
   void push(int);
   int pop();
   bool isFull() const;
   bool isEmpty() const;
};
intstack.cpp cannot be changed

using namespace std;

IntStack::IntStack(int size)
{
    stackArray = new int[size];
    stackSize = size;
    top = -1;
}

IntStack::~IntStack()
{
    delete [] stackArray;
}

void IntStack::push(int num)
{
    assert (!isFull());  // will exit program if this happens
    top++;
    stackArray[top] = num;
}

int IntStack::pop()
{
    assert(!isEmpty());  // will exit program if this happens
    int num = stackArray[top];
    top--;
    return num;
}

bool IntStack::isFull() const
{
    return (top == stackSize - 1);
}

//****************************************************
// Member funciton isEmpty returns true if the stack *
// is empty, or false otherwise.                     *
//****************************************************

bool IntStack::isEmpty() const
{
    return (top == -1);
}

int main()
{
    char filename;
    ifstream inFile;
    cout << "Enter the filename.";
    cin, filename;

    inFile.open("testing.txt");
    int c;


    if (!inFile)
    {
        cout << "File could now be opened. Program terminated."<< endl;
        return 1;
    }
    else






    inFile.close();
    return 0;
}

Recommended Answers

All 4 Replies

Given a text file, your program will determine if all the parentheses, curly braces, and 
square brackets match, and are nested appropriately. Your program should work for 
mathematical formulas and computer programs. 
!
Your program should read in the characters from the file, but ignore all characters 
except for the following: 
{ } ( ) [ ] 

Your program should prompt the user to enter a filename. It should then try to open 
the file and then check it make sure the brackets all match appropriately. If they all 
match, the program should output a message saying so. If not, the program should 
output an appropriate error message. 
!
There are three types of errors that can happen (and they can happen with any kind of 
bracket): 
! missing } : if you reach the end of the file, and there is an opening { that was 
never matched, like: int main () { x[size]=10; 
expected } but found ) : this is a wrong closing bracket, like: {x[i]=10;)... 
unmatched } : this occurs if there is a closing bracket but not an opening bracket 
(not even one of the wrong kind), like: int main () { x[i]=10; } }... 

on number 74, we dont read data like that. it must be cin>> filename
Also this is purely a homework that you have not touched. Its partially given by your instructor for you to do the res so be kind and show us what you have included so far ok?

You missed the opening brace for class InStack in your header file.

how can I read whats in the filename with an int stack

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.