/** * prob3.c * Sam's quick test of the code in problem 3. */ // +---------+-------------------------------------------------------- // | Headers | // +---------+ #include "hashtable.h" #include // +---------+-------------------------------------------------------- // | Helpers | // +---------+ static void backwards (struct hashtable *table, char *value) { char *key = find_key (table, value); if (key == NULL) printf ("%s has no corresponding key.\n", value); else printf ("%s's key is %s.\n", value, key); } // +------+----------------------------------------------------------- // | Main | // +------+ int main () { struct hashtable *table = new_hashtable (10); if (table == NULL) return 1; // The legendary hero/sidekick table assign (table, "Asterix", "Obelix"); assign (table, "Scooby-Doo", "Shaggy"); assign (table, "Bugs Bunny", "Daffy Duck"); assign (table, "Rocky", "Bullwinkle"); assign (table, "Bullwikle", "Rocky"); assign (table, "Mr. Peabody", "Sherman"); assign (table, "Secret Squirrel", "Morocco Mole"); assign (table, "Yogi Bear", "Booboo Bear"); assign (table, "Batman", "Robin"); assign (table, "Blondie", "Dagwood"); assign (table, "Bart Simpson", "Milhouse Van Housen"); // Now let's print it out. print_table (table); // And check key/value pairs backwards (table, "Dagwood"); backwards (table, "Obelix"); backwards (table, "Superman"); backwards (table, "Bart Simpson"); return 0; } // main ()