#include <iostream>
#include <iomanip>
#include <string>
#include <cstddef>
#include <cstring>
#include <fstream>
#include "IntStack.h"
using namespace std;
int main()
{
char c;
ifstream inFile;
string filename;
cout << "Enter the filename " << endl;
cin >> filename;
inFile.open(filename);
IntStack stack(50);
if (!inFile) //file could not be opened
{
cout << "File could now be opened. Program terminated." << endl;
return 1;
}
else if (inFile) //could be open
{
while (inFile >> c)
{
if (c == '(')
{
if (!stack.isFull())
{
stack.push(')');
}
else
{
cout << "Sorry stack is full. " << endl;
}
}
if (c == '[')
{
if (!stack.isFull())
{
stack.push(']');
}
else
{
cout << "Sorry stack is full. " << endl;
}
}
if (c == '{')
{
if (!stack.isFull())
{
stack.push('}');
}
else
{
cout << "Sorry stack is full. " << endl;
}
}
if (c == ')')
{
if (stack.isEmpty())
{
cout << "Sorry can't push out anything stack is Empty!";
}
else
{
char p = stack.pop();
if (c != p )
{
cout << "Error: Wanted " << c << "But Got" << p << endl;
}
}
}
};
}
}
ALL I NEED IS HOW TO GET THE LENGTH OF THE FILE THAT THE USER TYPED IN...