Created
May 14, 2013 21:24
-
-
Save Midiman/5579667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#include "Address.h" | |
#define NUM_FIELDS 4 | |
char *Person_fields[] = { | |
"Name", "Address", "Location", "Zip" | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
int num_people = 0; | |
int total_chars, | |
num_words = 0, | |
dest_field = 0, | |
dest_person = 0, | |
iter = 0; | |
char buffer[BUFSIZ]; | |
Address_t *addrs[ADDRESS_MAX]; | |
Address_t *addr_p = *addrs; | |
while( gets( buffer ) != NULL && (num_people < ADDRESS_MAX) ) { | |
iter++; | |
addr_p = (Address_t *)malloc(sizeof(Address_t)); | |
printf("%s\n", buffer); | |
addr_p->name = (char *)malloc(sizeof(strlen(buffer))); | |
strcpy(addr_p->name, buffer); | |
gets( buffer ); | |
addr_p->address = (char *)malloc(sizeof(strlen(buffer))); | |
strcpy(addr_p->address, buffer); | |
printf("%s\n", buffer); | |
gets( buffer ); | |
addr_p->area = (char *)malloc(sizeof(strlen(buffer))); | |
strcpy(addr_p->area, buffer); | |
printf("%s\n", buffer); | |
gets( buffer ); | |
addr_p->zip = (int)malloc(sizeof(int)); | |
addr_p->zip = atoi(buffer); | |
printf("%s\n", buffer); | |
printf("Print\n"); | |
printf("Name\t: %s", addr_p->name); | |
printf("Addr\t: %s", addr_p->address); | |
printf("Area\t: %s", addr_p->area); | |
printf("ZIP\t: %i", addr_p->zip); | |
num_people++; | |
addr_p++; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment