0

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.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by XodoX
0

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

0

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.

0

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?

Edited by XodoX: 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.