Sexcamera - Validating input in c

by  |  22-Mar-2016 15:26

Any ideas are welcome, thanx int isalnum(int c ); int isalpha(int c ); int isascii(int c ); int isblank(int c ); int iscntrl(int c ); int isdigit(int c ); int isgraph(int c ); int islower(int c ); int isprint(int c ); int ispunct(int c ); int isspace(int c ); int isupper(int c ); int isxdigit(int c ); Ok guys, this thing is too complicated omg... i wrote this function based on this: it works (at least for me) any coments or suggestions are welcome, thanx Yeah, there is a lot to know before you can use C effectively.

validating input in c-38

But the thing is it compiles but when i run it and i press a character such as the letter 'c' the program goes bolistic and goes into an inifinate loop how can i stop this with some validation to make sure that only an int is entered? Though you can more easily display your intentions by reversing the loop conditions: if the user input nothing before pressing ^D(unix like os) or ^Z(windows), and there is no such a test in function flush_stdin, then the program will stop and wait for the user to press ENTER.

By calling feof to test stdin, we can avoid this unexpected thing It do need to call feof.

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.

I suppose then you can turn into one of those bitter people that talk about how unsafe C is because they have no idea how to cover their asses against edge cases and got burned. the standard makes certain guarantees about the behavior of getchar when the stream is in an error state What kind of behavior does it guarantee?

Community Discussion