address-adt.c:
struct address
{
char street[50];
char city[50];
char province[50];
char postal_code[8];
};
struct address *new_address()
{
struct address *temp = malloc(sizeof(struct address));
temp->street[0] = '\0';
temp->city[0] = '\0';
temp->province[0] = '\0';
temp->postal_code[0] = '\0';
return temp;
}
int main(int argc, char **argv)
{
if (argc < 5)
{
printf("Usage: %s street city province postal_code\n", argv[0]);
exit(1);
}
struct address *my_address = new_address();
strcpy(my_address->street, argv[1]);
strcpy(my_address->city, argv[2]);
strcpy(my_address->province, argv[3]);
strcpy(my_address->postal_code, argv[4]);
printf("Address is:\n\t%s\n\t%s, %s\n\t%s\n",
my_address->street,
my_address->city,
my_address->province,
my_address->postal_code);
}
{
char street[50];
char city[50];
char province[50];
char postal_code[8];
};
struct address *new_address()
{
struct address *temp = malloc(sizeof(struct address));
temp->street[0] = '\0';
temp->city[0] = '\0';
temp->province[0] = '\0';
temp->postal_code[0] = '\0';
return temp;
}
int main(int argc, char **argv)
{
if (argc < 5)
{
printf("Usage: %s street city province postal_code\n", argv[0]);
exit(1);
}
struct address *my_address = new_address();
strcpy(my_address->street, argv[1]);
strcpy(my_address->city, argv[2]);
strcpy(my_address->province, argv[3]);
strcpy(my_address->postal_code, argv[4]);
printf("Address is:\n\t%s\n\t%s, %s\n\t%s\n",
my_address->street,
my_address->city,
my_address->province,
my_address->postal_code);
}