Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addInformation(Contact *myContacts, char *contactName, char *infoName, char *infoValue) {
- // check to see if contact exists
- while (strcmp(contactName, myContacts->name) != 0 ) {
- myContacts = myContacts->next;
- }
- if (myContacts == NULL) {
- printf("Contact not found");
- return myContacts;
- }
- Info *newNode = malloc( sizeof(Info) );
- newNode->name = malloc( sizeof(char) * strlen(infoName) + 1 );
- newNode->value = malloc( sizeof(char) * strlen(infoValue) + 1 );
- strcpy(newNode->name, infoName);
- newNode->value = infoValue;
- newNode->next = NULL;
- if (myContacts == NULL) {
- return newNode;
- }
- Contact *temp = myContacts;
- while (temp->next != NULL) {
- temp = temp->next;
- }
- temp->next = newNode;
- return myContacts;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement