Validating user input in c

NOTE: Though it has been deprecated to use gets() function, Instead of using gets, you want to use fgets().When the above code is compiled and executed, it waits for you to input some text.You are clearly violating the Single Responsibility Principle (SRP) because the method is doing two things.You should use two methods where each validates one type only.

Check the following example − When the above code is compiled and executed, it waits for you to input some text.C programming provides a set of built-in functions to read the given input and feed it to the program as per requirement.When we say Output, it means to display some data on screen, printer, or in any file.Also, you can use Regular Expressions in a Console app just as easily as you can in an ASP. Probably the reason validation isn't mentioned specifically to Console apps is that validation of input is validation of input. Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Leave a Reply