#include <stdio.h>
#include <string.h>
struct _Phone_Entry {
const char *name;
const char *number;
};
typedef struct _Phone_Entry Phone_Entry;
static Phone_Entry _start_entries[] = {
{ "Wolfgang Amadeus Mozart", "+01 23 456-78910" },
{ "Ludwig van Beethoven", "+12 34 567-89101" },
{ "Richard Georg Strauss", "+23 45 678-91012" },
{ "Heitor Villa-Lobos", "+34 56 789-10123" },
{ NULL, NULL }
};
static void
_phone_entry_free_cb(void *data)
{
free(data);
}
{
const char *name = key;
const char *number = data;
printf("%s: %s\n", name, number);
}
int
main(int argc, const char *argv[])
{
(void) argc;
(void) argv;
int i;
const char *entry_name = "Heitor Villa-Lobos";
char *phone = NULL;
void *data;
for (i = 0; _start_entries[i].name != NULL; i++)
{
strdup(_start_entries[i].number));
}
if (phone)
{
printf("Printing entry.\n");
printf("Name: %s\n", entry_name);
printf("Number: %s\n\n", phone);
}
printf("Hash entry successfully deleted? %d\n\n", r);
strdup("+23 45 111-11111"));
free(phone);
strdup("+55 01 234-56789"));
if (!phone)
{
printf("No previous phone found for Raul Seixas. ");
printf("Creating new entry.\n");
}
else
{
printf("Old phone for Raul Seixas was %s\n", phone);
free(phone);
}
printf("\n");
strdup("+55 02 222-22222"));
if (phone)
{
printf("Changing phone for Raul Seixas to +55 02 222-22222. ");
printf("Old phone was %s\n", phone);
free(phone);
}
else
{
printf("No previous phone found for Raul Seixas. ");
printf("Creating new entry.\n");
}
printf("List of phones:\n");
printf("\n");
printf("List of phones:\n");
{
const char *name = t->key;
const char *number = t->data;
printf("%s: %s\n", name, number);
}
printf("\n");
printf("List of names in the phone book:\n");
{
const char *name = data;
printf("%s\n", name);
}
printf("\n");
printf("List of numbers in the phone book:\n");
{
const char *number = data;
printf("%s\n", number);
}
printf("\n");
printf("There are %d items in the hash.\n\n",
printf("List of phones after change:\n");
printf("\n");
printf("There are %d items in the hash.\n\n",
}