I've got my code so that when I enter "1" it adds an entry, "2" to delete entry, and "3" to print the pb.... I want the commands to be in letters as seen in the printf. I'm not sure how to put into arrays..
Code:
#include <stdio.h>
#include <string.h>
int i;
int number_of_entries;
typedef struct{
char first [15];
char last [15];
char phone [15];
}phonebook;
main (){
phonebook entry[50];
int response;
printf("\n\tPhonebook\n\n");
printf("(A)Add an entry\n");
printf("(D)Delete an entry\n");
printf("(P)print the phonebook\n");
printf("(Q)quit\n");
printf("Enter selection: ");
scanf("%d", &response);
switch (response){
case 1:
number_of_entries++;
printf("Enter First Name: ");
scanf("%s", entry[i].first);
printf("Enter Last Name: ");
scanf("%s", entry[i].last);
printf("Enter Phone Number: ");
scanf("%s", entry[i].phone);
return 0;
break;
case 2:
case 3:
for(i; i<number_of_entries; i++){
printf("%s, %s, %s", entry[i].last, entry[i].first, entry[i].phone); }
return 0;
break;
}
system("pause");
return 0;
}