Tutorial by Examples

#include <ctype.h> #include <stdio.h> typedef struct { size_t space; size_t alnum; size_t punct; } chartypes; chartypes classify(FILE *f) { chartypes types = { 0, 0, 0 }; int ch; while ((ch = fgetc(f)) != EOF) { types.space += !!isspace(ch); types.al...
#include <ctype.h> #include <stddef.h> typedef struct { size_t space; size_t alnum; size_t punct; } chartypes; chartypes classify(const char *s) { chartypes types = { 0, 0, 0 }; const char *p; for (p= s; p != '\0'; p++) { types.space += !!isspace((unsigned ...
The header ctype.h is a part of the standard C library. It provides functions for classifying and converting characters. All of these functions take one parameter, an int that must be either EOF or representable as an unsigned char. The names of the classifying functions are prefixed with 'is'. Ea...

Page 1 of 1