.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)

Step 1 is figure out which language you're programming in. This is the C++ forum, and the code you tried to compile was (as far as the compiler was concerned) C++.
What you actually wrote however was all C.

The second step is step back and think about what you're doing.
http://cboard.cprogramming.com/c-programming/88495-development-process.html

Start with some simple functions like

void add_num ( void ) {
  printf("Called add_num\n");
}
void lookup ( void ) {
  printf("Called lookup\n");
}

Now create a simple main which prints a menu, and calls one of the above.
WHEN all that works adequately, then move onto the next little step you can think of.

Oh, and don't neglect indentation (also a mess in your code)
http://sourceforge.net/apps/mediawiki/cpwiki/index.php?title=Indentation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.