Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void phone_book()
{
char name[5],addr[6],e_id[7];
int ph;
printf("enter the name\n");
fgets(name,sizeof(name),stdin);
printf("enter the address\n");
fgets(addr,sizeof(addr),stdin);
printf("enter the email id \n");
fgets(e_id,sizeof(e_id),stdin);
printf("enter th phone no\n");
scanf("%d",&ph);
}
int main()
{
int ch,c;
printf("PHONE BOOK\n");
printf("Menu\n");
printf("1.Write 2.Show c.Search d.Edit e.Exit\n");
scanf("%d",&ch);
while ((c = getchar()) != '\n' && c != EOF)
switch(ch)
{
case 1 : phone_book();
break;
default : printf("invalid");
break;
}
return 0;
}
For some reason,this code is working properly without the semicolon,please have a look.