Boolean data type is a data type that has one of two possible values (usually denoted true and false) which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole (picture, below), who first defined an algebraic system of logic in the mid 19th century.  Also investigated are the 'enum' (enumeration) keyword and using 'strtok()' function to break a string into designated tokens (sub-strings).

 

(right-click to download)

/* pgm18 source */

#include <stdio.h>
#include <string.h>

// if all enumerators are un-valued, they begin at '0' and count up +1
// by the way, these color codes are how electronic resistor values are identified
enum colorvals {BLACK, BROWN, RED, ORANGE, YELLOW, GREEN, BLUE, VIOLET, GREY, WHITE};

// any un-valued enumeration takes on +1 from its left neighbor
// generally, 'boolean' data is - primatively - one or zero, true or false, or the like...
enum boolvals {RET_FAIL = -1, RET_OK, ISFALSE = 0, ISTRUE};

int main(int argc, char *argv[]) {
     char *token;
     char cute_line[] = "A young girl came down the walk, singing Frère Jacques";
     int flag;
     int x;

     if (argc > 1) {
          printf("\nWhy, oh why did you give a command-line parameter??\n\n");
          return(RET_FAIL);
          }

     printf("\n");

     flag = ISTRUE;
     while (flag) {
          token = strtok(cute_line, " "); // " " (string containing a single space) is the DELIMITER
          while (token != NULL) {
               printf("%s\n", token);
               token = strtok(NULL, " ");
               }
          flag = ISFALSE;           // this will cause exit from the OUTER 'while ()' loop
          }

     printf("\n");
     x = 0;
     while (ISTRUE) {
          putchar('.');

          if (++x == 408) {           // ++x means "increment BEFORE applying the logic test
               printf(" Whoa, almost had an infinite loop there!\n\n");
               break;                     // ...out of the nearest enclosing loop construct
               }
          }

     printf("\n");
     printf("All 'boolsvals': %d %d %d %d\n", RET_FAIL, RET_OK, ISFALSE, ISTRUE);
     printf("3 'colorvals': RED is %d, GREEN is %d, VIOLET is %d\n\n", RED, GREEN, WHITE);

     return(RET_OK);
}