Question: This is C. Below is my code i am still running into some errors as well i will post below (1) Create three files to

This is C. Below is my code i am still running into some errors as well i will post below

(1) Create three files to submit.

Contacts.h - Struct definition, including the data members and related function declarations

Contacts.c - Related function definitions

main.c - main() function

(2) Build the ContactNode struct per the following specifications:

Data members

char contactName[50]

char contactPhoneNum[50]

struct ContactNode* nextNodePtr

Related functions

CreateContactNode() (2 pt)

InsertContactAfter() (2 pts)

Insert a new node after node

GetNextContact() (1 pt)

Return location pointed by nextNodePtr

PrintContactNode()

Ex. of PrintContactNode() output:

Name: Roxanne Hughes Phone number: 443-555-2864 

(3) In main(), prompt the user for three contacts and output the user's input. Create three ContactNodes and use the nodes to build a linked list. (2 pts) Ex:

Person 1 Enter name: Roxanne Hughes Enter phone number: 443-555-2864 You entered: Roxanne Hughes, 443-555-2864 Person 2 Enter name: Juan Alberto Jr. Enter phone number: 410-555-9385 You entered: Juan Alberto Jr., 410-555-9385 Person 3 Enter name: Rachel Phillips Enter phone number: 310-555-6610 You entered: Rachel Phillips, 310-555-6610 

(4) Output the linked list. (2 pts) Ex:

CONTACT LIST Name: Roxanne Hughes Phone number: 443-555-2864 Name: Juan Alberto Jr. Phone number: 410-555-9385 Name: Rachel Phillips Phone number: 310-555-6610 

Code plus errors

/*Contacts.h*/

#ifndef CONTACTS_H_INCLUDED

#define CONTACTS_H_INCLUDED

struct ContactNode { char ContactName[50]; char ContactPhone[50]; struct ContactNode* nextNodePtr; };

struct ContactNode* CreateContactNode(struct ContactNode* p, char name[], char phone[]);/*create a new node*/ struct ContactNode* InsertContactAfter(struct ContactNode* p,char name[], char phone[]); /*insert a new node after node*/ struct ContactNode* GetNextContact(struct ContactNode* p); /*Return Location Pointed by nextNodePtr*/ void PrintContactNode(struct ContactNode* p); /*print a node*/

#endif // CONTACTS_H_INCLUDED

_______________________________________________________

/*Contacts.c*/

#include #include #include #include"Contacts.h"

struct ContactNode* CreateContactNode(struct ContactNode* p, char name[], char phone[])/*create a new node*/ { if((p=(struct ContactNode*)malloc(sizeof(struct ContactNode)))==NULL) { printf("Error - Could not allocate memory. Exiting... "); exit(0); } strcpy(p->ContactName,name); strcpy(p->ContactPhone,phone); p->nextNodePtr=NULL; return(p); } struct ContactNode* InsertContactAfter(struct ContactNode* p,char name[], char phone[]) /*insert a new node after node*/ { struct ContactNode* temp; if(p==NULL) /*if list is empty*/ { p=CreateContactNode(temp,name,phone); return(p); /*create and return the first node in the list*/ } else { temp=CreateContactNode(temp,name,phone); p->nextNodePtr=temp; /*create a new node and link it to the previous node in the list*/ } return(temp); } struct ContactNode* GetNextContact(struct ContactNode* p) /*Return Location Pointed by nextNodePtr*/ { return p->nextNodePtr; } void PrintContactNode(struct ContactNode* p) /*print a node*/ { printf(" Name: %s ",p->ContactName); printf("Phone Number: %s ",p->ContactPhone); }

___________________________________________________________

/*main.c*/

#include #include #include"Contacts.h" int main() { struct ContactNode* start; struct ContactNode* t; int i; char Name[50],phoneNo[50]; for(i=1;iContactName,t->ContactPhone); }

/*print the list*/ printf(" CONTACT LIST"); t=start; /*print out the list by traversing each node from start to end*/ while(t) { PrintContactNode(t); t=GetNextContact(t); } }

Current Errors

This is C. Below is my code i am still running into

some errors as well i will post below (1) Create three files

SUBMITTED: 08:05 AM ON 03/06/17 1. Unit test Tests that CreateContactNode0 initializes a node with name "Jane Doe" and phone number "555-555-5555" 2. Compare output Roxanne Hughes 443-555-2864 Juan Alberto Jr. Input 410-555-9385 Rachel Phillips 310-555-6610 Person 1 Enter name: Enter phone number: You entered: Roxanne Hughes, 443-555-2864 Person 2 Enter name: Your output comectly starts with Enter phone number: You entered: Juan Alberto Jr., 410-555-9385 Person 3 Enter name: Enter phone number: You entered: Rachel Phillips, 310-555-6610 3. Compare output David Frederick 240-555-2104 Bernard Green Total: 4/9 0/2 SUBMITTED: 08:05 AM ON 03/06/17 1. Unit test Tests that CreateContactNode0 initializes a node with name "Jane Doe" and phone number "555-555-5555" 2. Compare output Roxanne Hughes 443-555-2864 Juan Alberto Jr. Input 410-555-9385 Rachel Phillips 310-555-6610 Person 1 Enter name: Enter phone number: You entered: Roxanne Hughes, 443-555-2864 Person 2 Enter name: Your output comectly starts with Enter phone number: You entered: Juan Alberto Jr., 410-555-9385 Person 3 Enter name: Enter phone number: You entered: Rachel Phillips, 310-555-6610 3. Compare output David Frederick 240-555-2104 Bernard Green Total: 4/9 0/2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!