Thanks for the welcome, I assume I will be using this resource alot during my time at CECS school haha.Thanks for the responce and I apologize for not knowing but here is the code again:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//Defining my variables
int entry;
int contactsnum=0;
int i=0;
//Defining my struct
typedef struct phonebook
{
char firstName[20];
char lastName[20];
char number[20];
}con;
//Attempting to create a code for adding and removing items in con struct
con * AddItem (con * conlist);
con * RemoveItem (con * conlist);
//main function
main(){
phonebook entry[100];
phonebook* contacts;
con=(phonebook*)malloc(sizeof(con)*sizeof(con));
//problem with this line compiler won't compile
con p;
int choice=0;
//A do while loop allows for constent adding and remove
do{
con listmember, *conlist;
char firstName[20];
char lastName[20];
char number[11];
printf("Hello, Welcome to Command Prompt Phonebook.\n");
printf("Please Select an option:\n");
printf("(1) Add Contact\n");
printf("(2) Delete Contact\n");
printf("(3) Search Phonebook\n");
printf("(4) Exit Program\n");
printf("Enter Selection:");
scanf("%d",&choice);
//switch for choices
switch(choice){
case 1:
printf("\nYou chose Add Contact:\n");
printf("\nPlease Enter First Name:");
scanf("%s",&p.firstName);
conlist=AddItem (contact,p.firstName);
printf("\nPlease Enter Last Name:");
scanf("%s",&p.lastName);
conlist=AddItem (con,p.lastName);
printf("\nPlease Enter Phone Number:");
scanf("%s",&p.number);
conlist=AddItem (con, number);
printf("\nNumber Added to Phonebook");
break;
/* The code I wrote here doesn't work. I get "expected
primary-expresion before '=' token" I don't really understand
whats wrong with it */
case 2:
printf("You chose Delete Contact:");
printf("Please Enter First Name:");
scanf("%d",&p.firstName);
conlist=RemoveItem (con,p.firstName);
printf("Please Enter Second Name:");
scanf("%d",&p.lastName);
conlist=RemoveItem (con,p.lastName);
printf("Please Enter Number:");
scanf("%f",&p.number);
conlist=RemoveItem (con,p.number);
printf("Number has been deleted");
break;
// Same problem
case 3:
printf("\nCommand Prompt Phonebook Contents:");
printf("\nFirst Name:%d",&p.firstName);
printf("\nLast Name:%d",&p.lastName);
printf("\nPhone Number:%f",&p.number);
break;
// Haven't really worked at this yet
default:
printf("Please Enter Valid Number");
case 4:
break;
}
}while(choice!=4);
printf("\nThanks for using! Goodbye!\n");
system("pause");
}
Thanks again for all the help!