Validating c input updating phone

Rated 4.10/5 based on 602 customer reviews

I am also a freelance writer with over 3 years of writing high-quality, SEO optimized content for the web.

I have written for startups, websites, and universities all across the globe.

If this interpretation succeds, then the value thus found is stored in the integer variable you passed as argument. Since you expect only one input, the value 1 will indicates that everything was fine.

C has some good validation techniques that can be used to validate most kind of inputs.

But it's not evaluated by a human but by a machine, and that machine expects the code to do exactly what it instructed you to do and nothing more, the task asks that you check to see if a number is negative and print a message if it is, but that is also all that it asks.

It does not ask you to add a loop that continually prompts for new input when the number given is wrong, logically adding such a loop is correct, and if you were making this program for real, most people would indeed add one.

The reason behind this is when you hit return\enter on your keyboard, a newline character is passed in as input.

These extra hidden characters are what is messing with your input and spawning the infinite while loop.

Leave a Reply