+ 1

How can I forbid the use of characters?

How can I prevent the user from using letters other than the ones offered in a program's options/parametters?

13th Dec 2018, 8:24 PM
Juan Sixto Nathan
Juan Sixto Nathan - avatar
3 ответов
+ 1
You can either filters those characters out, or return an error message and let them enter a different input
13th Dec 2018, 8:50 PM
Julian
Julian - avatar
+ 2
What I am trying to do is to sanitize the input, I already have a part of my code that prevents the use of numbers... If (character <= 0 || character >= 0){ printf (.......); exit (1); } But now I want to prevent the use of certain letters that do not provide any functionality in the program, like let's suppose z, v, r, et cetera.
13th Dec 2018, 9:23 PM
Juan Sixto Nathan
Juan Sixto Nathan - avatar
+ 2
Have a look at the c standard lib string.h that should contain a method to do the job. However, regex are also a way to go.
13th Dec 2018, 11:39 PM
Loeschzwerg