#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...

Recommended Answers

All 2 Replies

I looked at it but I dont understand it very well

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.