Hi, I am writing a mathematical program in C++ and am having a couple of problems.
The user inputs a number of entries in the form
( type parameter1 parameter2 weight ) eg
>> ( alpha 2 3 0.4 ) + ( gamma 6 2 0.6 )
The above is one input with 2 entries. There are only 5 types of names, and the type of the name determines the manner in which the parameters in an entry are used.
The user can enter as many entries as he wishes.
What I am having problems with is how to read the entries and
how to store them.
Im thinking of using arrays, and storing similar elements in
the same array, so
I would get something like below
name_array = alpha name_array= gamma
param1_array = 2 param1_array = 6
param2_array = 3 param2_array = 2
weight_array = 0.4 weight = 0.6
What I would like to know is:
How to read the input and store the individual elements of an entry??
How would I read the input so that the program recognises what it is reading is the name, or what it is reading is the 2nd parameter. The program should be able to cope with more than 1 whitespace between different elements in an entry.
any help or ideas would be really appreciated.