+ 1

How to check if the user's input doesn't contain parentheses?

I am coding a program that should calculate various values of a geometric shape or form. So far I've completed the code for squares and rectangles only on the 2nd dimension and I had a problem with the surface becoming negative for example if the user inputs a positive number between parentheses http://cpp.sh/6y5zh I suggest you check function aPositive() at the bottom since it's the one containing the a variable which should be positive and a float.I want to make a loop that checks if the input contains:()

14th Nov 2017, 2:42 PM
Anouar Achghaf
Anouar Achghaf - avatar
8 Réponses
+ 1
I do this example, you can detect the pharenteses looking for his ASCII value, for example, into a for loop. But you can choice other ways to resolve it. https://code.sololearn.com/csCoGVFAJY4Z/?ref=app
14th Nov 2017, 6:24 PM
Iago
Iago - avatar
+ 1
Can you copy your code to Code Playground? then link the code with the question, hopefully that way people can easily view your code and offer suggestions. :)
14th Nov 2017, 3:21 PM
Ipang
14th Nov 2017, 3:56 PM
Anouar Achghaf
Anouar Achghaf - avatar
0
so if I want to run an error if the user inputs parentheses do I do while (check>=1) { cout << "error"; cin >> example; } ?
14th Nov 2017, 6:45 PM
Anouar Achghaf
Anouar Achghaf - avatar
0
You must detect the number into (). Not only the pharenteses, its correct?
14th Nov 2017, 6:54 PM
Iago
Iago - avatar
0
oh yeah I either want to detect the number inside and keep the code running or give the user an error and not detect the number
14th Nov 2017, 6:55 PM
Anouar Achghaf
Anouar Achghaf - avatar
0
and why did you make the array length constant if it's the user's entry
14th Nov 2017, 6:56 PM
Anouar Achghaf
Anouar Achghaf - avatar
0
That code is only a example to detect a pharenteses. About the error, you are the programmer, you decide it
15th Nov 2017, 2:11 AM
Iago
Iago - avatar