ok so i need to ask the user for a file to use for the input, then i need to read the input a line at a time, because i am trying to take postfix expressions from the file and evaluate them then return the result in the user's choice of a text file or just on the screen. The problem i am having now is i dont know how to take the user's input from their file and read a line at a time and put it into a stack im so confused. any help would be great thanks.

	Postfix Evaluation Program
	Version 1.0
	This is a program that takes a file from the user and evaluates postfix expressions from the file.
	Source File:  postfixEval.cpp

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
//include stack
using namespace std;

int main()
	char inFileName[60];
	string outFileName;

	cout << "Enter the name of the input file --> ";
	cin >> inFileName;
	cout << endl << endl;

	ifstream postfixFile;  // Input filestream variable
	// Attempt to open the file
	// Check to make sure it opened
	if( postfixFile.fail() )
		cout << "Error opening input file." << endl;

	while( !postfixFile.eof() )
		//have user input placed into stack here!!
	cout << "The file contained " << numChars << " characters." << endl;
	// Close the file -- necessary if the file is to be reread
	cout << "Enter the name of the output file --> ";
	cin >> outFileName;
	cout << endl << endl;
	ofstream resultFile; // Output filestram variable
	// Attempt to open the file
	resultFile.open(outFileName.c_str());  // Filename must be a cstring
	// Check to make sure it opened
	if( resultFile.fail() )
		cout << "Error opening output file." << endl;

	// Write some stuff to the file
	myOut << "This is written to the file." << endl;
	// Be sure to close the file -- otherwise it may not be created
6 Years
Discussion Span
Last Post by v3ga

Where's myIn and myOut declared?

its not it myin should be postfixFile and myout should be resultFile


Use getline.. myIn.getline(expression,SIZE,delimiter). SIZE is no of characters, delimiter denotes end of input default '\n'

Edited by v3ga: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.