The input is in a text file and it being read by the code and stored in "line" by using getline. The input is just math operations.. 1*8+2 etc. Only * and +, nothing else. But the file can also contain invalid strings such as

"1++"
"1+2*+4"
"2 + A + 3 + C""2**3**4"

etc. It can only two integers joined by * and + . I think I can tokenize the input and then check it against the requirement, correct? How do I do this? And, do I have to check for each invalid input or can I just define a valid input and it automatically identifies it? If not, I would have to check for quite a few things.

Can't edit the post anymore, but it's of course "tokenize". Sorry.

Its up to you, you can scan through a instance of '+' and assert that there are numbers in the left and right of it, and the same for '*'. Try looking into 'postfix' as well.

Scan through it how? What method? I don't know. Never heard of postfix, but I will look into it. It's just the first data structure class I'm taking. It shouldn't be anything too complex. But you have a good idea there. The requirement needs to be an integer and a * or + right next to it. That way I should have covered many invalid inputs ( maybe not all) , correct?

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.