cybersecurity · beginner · ~15 min
Detect non-alphanumeric characters.
Detect whether a password contains a non-alphanumeric character.
Implement int has_special(const char *pw) that returns 1 if pw contains at least one character that is not a letter or a digit, else 0.
pw: a NUL-terminated password string the grader passes.Returns int: 1 if any character is outside [A-Za-z0-9], else 0.
has_special("abc!23") -> 1 (the '!')
has_special("abc123") -> 0
A NUL-terminated password string pw.
An int: 1 if pw has a character outside [A-Za-z0-9], else 0.
A character that is not a letter or digit counts as special.
int has_special(const char *pw) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.