.the program should use singly linked list of records.It should print he original directory then make some insertion and deletions then print the final directory.
it should follow the steps
1. input initial listings such as name, address, and phone number.
2. input update records such as 'I' for insert, 'D' for delete. name, address, number.
each record represents a change. insert the entries in alphabetical order by last name.
3. output the list after updating the records. it should be alphabetized. allow one line in each entry for name, street, address, and number. include the appropriate headings.
//a simple telephone directory
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
void add_num(void), lookup(void);
int menu(void);
main()/*fscanf-fprintf*/
{
char choice;
do{
choice=menu();
switch(choice){
case'a': add_num();break;
case'b':lookup();break;
}
} while (choice!='q')
menu()
{
char ch;
do{
printf("[A]dd\n[L]ook up\n[Q]uit:\n");
ch=tolower(getche());
printf("\n");
}
while(ch!='q'&&ch!='a'&&ch!='l');
return ch;
}//end of menu
// add a name and number to the directory
void add_num()
{
FILE *fp;
char name[80];
int a_code, exchg,num;
//open it for append
if((fp=fopen("phone","a"))==NULL)
{printf("cannot open directory file \n");
exit(1);
printf("ENTER NAME AND NUMBER: ");
fscanf(stdin,"%s%s%d%d%d",&name,&a_code,&exchg,&num);
fscanf(stdin,"%c");
fprintf(fp,"%s%s%d%d5d\n",name,a_code,exchg,num);
fclose(fp);
}
void look_up()
{
FILE *fp;
char name[80],name2[80];
int a_code exchg,num;
if((fp=fopen("phone","r"))==NULL)
{
printf("cannot open directory file\n");
exit(1);
}
printf("NAME: ");
gets(name);
while (!feof(fp))
{
fscanf(fp,"%s%d%d%d",name2,&a_code,&exchg,&num);
if(!strcmp(name,name2))
{
printf("%s: (%d) %d-%d\n",name,a_code.exchg,num); break;
}
}
fclose(fp);
}
i'm not finished in this program..what's the problem with this..
21 C:\Documents and Settings\k-9\My Documents\telephonebook.cpp expected `;' before
22 C:\Documents and Settings\k-9\My Documents\telephonebook.cpp expected `;' before '{' token "menu"
23 C:\Documents and Settings\k-9\My Documents\telephonebook.cpp expected `;' before "char"
26 C:\Documents and Settings\k-9\My Documents\telephonebook.cpp `ch' undeclared (first use this function)