Question
This is C I am not sure on why I am getting these remaining two error any help would be appericated. Current errors; My Code
This is C I am not sure on why I am getting these remaining two error any help would be appericated.
Current errors;
My Code
Contacts.C
#include
#include
#include
#include"Contacts.h"
struct ContactNode* CreateContactNode(struct ContactNode* p, char name[], char phone[]){
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[]){
struct ContactNode* temp;
if(p==NULL){
p=CreateContactNode(temp,name,phone);
return(p);
}
else{
temp=CreateContactNode(temp,name,phone);
p->nextNodePtr=temp;
}
return(temp);
}
struct ContactNode* GetNextContact(struct ContactNode* p) {
return p->nextNodePtr;
}
void PrintContactNode(struct ContactNode* p) {
printf(" Name: %s ",p->ContactName);
printf("Phone number: %s ",p->ContactPhone);
}
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[]);
struct ContactNode* InsertContactAfter(struct ContactNode* p,char name[], char phone[]);
struct ContactNode* GetNextContact(struct ContactNode* p);
void PrintContactNode(struct ContactNode* p);
#endif
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;i
{
printf(" Person%d ",i);
printf("Enter name: ");
gets(Name);
printf("Enter phone number: ");
gets(phoneNo);
if(i==1)
{
start=CreateContactNode(t,Name,phoneNo);
t=start;
}
else
t=InsertContactAfter(t,Name,phoneNo);
printf("You entered: %s, %s ",t->ContactName,t->ContactPhone);
}
printf(" CONTACT LIST");
t=start; while(t)
{
PrintContactNode(t);
t=GetNextContact(t);
}
}
1. Unit test Tests that CreateContactNode() 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 correctly 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 1. Unit test Tests that CreateContactNode() 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 correctly 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-6610Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started