If you have a char array[] that can hold arbitrary binary data, some of the values can be negative, since char is usually signed. isapha(array[i]) is undefined behavior if array[i] is a negative value other than EOF. If it doesn't crash, it will likely index backwards into a lookup table and access garbage.
EDIT: I see from the dead reply that this is a bot, or a "vibe coder" who doesn't understand the code. The bizarre remark "<ctype h> is solely to allow me to define structs using typdef" is nonsensical. Whoever (or whatever) wrote the code understands that <ctype.h> provides functions like isalpha and is unrelated to defining C types.
I'm 100% human, but also 100% amateur. Until 5 minutes ago, I understood <ctype h> to be necessary for me to use typedef to enable me to refer to structs by an alias, instead of writing "struct"! The perils of being self-taught. Now I can see the only errors thrown up when I remove the include are isdigit and isalnum! This is why I posted on HN!
EDIT: I think I can fix the isalnum bug risk that you identified by checking that the value of the ch variable in the get_string_input function is non-negative before allowing it to be appended to str.
The problem is that multi-byte data like UTF-8, stored in char strings, produces negative values. The can't just throw those away.
The usual workaround for the nasty <ctype.h> functions is to cast the char value to unsigned char.
if (isalnum((unsigned char) str[i])) ..
type of thing. The <ctype.h> functions also have locale-specific behavior. What is an alphabetic character depends on locale. For instance various ISO Latin characters may be alphabetic. Unfortunately, those characters are also in the range of UTF-8 continuation bytes (128-255). If you blindly apply <ctype.h> on UTF-8 data in a program that has called setlocale() to establish some locale, you can get weird results.
If you intend to test for the ASCII alphabetic characters, and nothing else, no matter what the locale is set to, then your best bet is (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z').
Thanks, this is the kind of feedback my hobbyist ass needs. My intention in including <ctype h> is solely to allow me to define structs using typdef. I'm not aware of any crashes or compiler warnings caused by the potential abuse, but I'm going to look at it later.