/** * dnf.c * Read a flag description from the command line, run the DNF algorithm, * and then print the result. */ // +---------+------------------------------------------------------- // | Headers | // +---------+ #include "flag.h" #include #include // +---------+------------------------------------------------------- // | Helpers | // +---------+ void flag_fun (char *str, int len) { color flag[len]; // Build the flag for (int i = 0; i < len; i++) { switch (str[i]) { case 'R': case 'r': flag[i] = RED; break; case 'W': case 'w': flag[i] = WHITE; break; case 'B': case 'b': flag[i] = BLUE; break; default: fprintf (stderr, "Illegal letter: %c\n", str[i]); flag[i] = RED; } // switch } // for // Run the algorithm dnf (flag, len); // And print the result printflag (flag, len); } // flag_fun // +------+---------------------------------------------------------- // | Main | // +------+ int main (int argc, char *argv[]) { flag_fun (argv[1], strlen (argv[1])); return 1; } // main