First of all, this is not really C++. <iostream.h>
has never been part of the C++ standard and has therefore been outdated at least 15 years. And aside from the cout
part, there is no C++ left. The procedural approach, the use of a fixed char array instead of a dynamic reziable string, the headers you include and the lack of classes make the rest of your program pure C code.
To parse the input from a file instead of the console, just open a corresponding filestream, get the input from there and parse it. You might want to refactor your program first a bit, e.g. using a string instead of the error prone char[]
, maybe throw an exception instead of just exiting the application in case of errors, and then wrap your parser logic into a class.
I highlighted some words there, which, reading your code, I think you might not be familiar with. Look them up in the C++ textbook of your choice. It will help you a lot if you want to create more complex programs.