Question:
How do I handle white space in validating user input more effectively in c++?
asd
2012-03-31 00:21:42 UTC
If I allow user to enter input in the form of method(variable, variable), how do I validate against white space?

For example, "method ( a , b )" should be the same as "method(a,b)" and it should be a valid input. Initially, I thought of removing all the white spaces in the input and validate from there on. However, if the user were to enter an invalid input such as "method ( a b , c )", it would have treated it as valid since it would become "method(ab,c)". So is there a better way to validate against such inputs or should I try to anticipate all the various types of cases that user can enter?
Three answers:
Sadsongs
2012-03-31 01:04:30 UTC
Start writing regular expressions and checking against those.
James Bond
2012-03-31 07:25:06 UTC
You are supposed to anticipate all the various types of classes that user an enter
?
2012-03-31 07:28:29 UTC
check the input is in correct format then make a trim function that removes extra space?idk


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...