You can read a character string from the user with scanf, then convert it to an integer with strtol.
For example, try the following program: Test it with 123, then with 123abc.
This condition can be cleared by calling the clear() function.
Secure programming is about making sure that inputs from bad people do not do bad things.
Indeed, most of the soon-to-be-released Secure Programming Cookbook for C and C addresses how to deal with malicious inputs.
Rules can be collected through the requirements capture exercise.
In evaluating the basics of data validation, generalizations can be made regarding the different types of validation, according to the scope, complexity, and purpose of the various validation operations to be carried out.