int main(int argc, char** argv) { ifstream fileInput; fileInput.open(argv[1]); IntStack *stack = new IntStack(); int value; while (fileInput.peek() != EOF) { while ((fileInput.peek() != '\n') && (fileInput >> value)) { stack->push(value); } fileInput.get(); // chomp the newline while (!stack->isEmpty()) { cout << stack->pop() << " "; if (!stack->isEmpty()) { stack->pop(); } } cout << endl; } }