ctype pitfall C is a language that I know fairly well. A few days ago I've learned something I didn't know about its standard library. It came out of a casual discussion with dave0, on the #c IRC channel (LiberaChat). In short, when invoking ctype functions such as isspace(3), the argument *must* be cast to unsigned char. All these functions have a common signature: they accept an `int` parameter. The important bit to keep in mind that they're defined only for EOF and the values in the [0, UCHAR_MAX] range. I would recommend to have a look at the relevant man-pages, of many operating systems: the problem is discussed in different ways, and in some instances not even mentioned. I believe it is generally a good idea to read the man pages, even for functionalities that seem trivial. If the manpage is longer than a few lines, it should be considered a red flag.