Hey /prog/. I have wrote a program in C that asks for the user to enter a string. How would I go about validating the input and making sure only alphabetic characters or spaces are accpeted as valid input?
Create an iterator that yields each character in succession, then map that with a function that checks whether a character is alphanumeric or not. Ensure that the results are all positive.
Alternatively, just use a fucking for loop to check each character. This takes literally two lines of code no matter how verbose you write it, and is probably better fit to C.
Name:
Anonymous2012-10-24 4:11
Use the isalpha and isspace standard library functions in the ctype.h header file.