Advertisement
KaeruCT

Untitled

Dec 13th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include "map.h"
  2.  
  3. void print_key(struct Map *map, char *key)
  4. {
  5.     printf("%s: %s\n", key, Map_get(map, key));
  6. }
  7.  
  8. int main(int arcg, char *argv[])
  9. {
  10.     struct Map *map = Map_create();
  11.     printf("Map length: %d\n", map->length);
  12.    
  13.     Map_put(map, "name", "Andres");
  14.     Map_put(map, "age", "17");
  15.     Map_put(map, "favorite drink", "coffee");
  16.     Map_put(map, "favorite color", "blue");
  17.    
  18.     print_key(map, "name");
  19.     print_key(map, "age");
  20.     print_key(map, "favorite color");
  21.     print_key(map, "favorite drink");
  22.     printf("Map length: %d\n", map->length);
  23.    
  24.     Map_remove(map, "age");
  25.     print_key(map, "age");
  26.     printf("Map length: %d\n", map->length);
  27.    
  28.     Map_put(map, "age", "18");
  29.     print_key(map, "age");
  30.     printf("Map length: %d\n", map->length);
  31.    
  32.     free(map);
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement