Anjani M.

asked • 11/22/14

c programing question for phonebook application

/*phonebook application*/

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,number[10],b,c,given[10],g,entry[10];
char find[15];
struct phonebook
{
char name[15];
int number[10];
};
struct phonebook contacts[15];
printf("enter the numbers you want to save (<= 10)");
scanf("%d",&n);
printf("enter the contact name and number \n");
for(c=0;c<n;c++)
{
scanf("%c %d",&contacts[c].name[15],&contacts[c].number[10]);
}
printf("enter 1 to add phone number \n");
printf("enter 2 for deleting phone number \n");
printf("enter 3 for modifing phone number \n");
printf("enter 4 for searching phone number \n");
scanf("%d",&i);
switch (i)
{
case 1:printf("\n enter the phone number");
for(b=n;b<15;b++)
{
scanf("%d",contacts[b].number[10]);
}
break;
case 2:printf(" \n enter the number u want to delete");
for(g=0;g<10;g++)
{
scanf("%d",given[g]);
}
for(c=0;c<15;c++)
{
if(contacts[c].number[10]==given[10])
{
contacts[c].number=contacts[c+1].number;
printf("\n the number is deleted");
}
else
printf("\n the number entered was not found");
}
break;
case 3:printf("enter contact name");
scanf("%s",find[15]);
for(i=0;i<b;i++)
{
if(contacts[i].name[15]==find[15])
{
printf("\n enter the number");
scanf("%d",entry[10]);
contacts[i].number[10]=entry[10];
}
else printf("\n no contact found");
}
break;
case 4:printf("\n enter the phone number");
scanf("%d",&given[10]);
for(i=0;i<n;i++)
{
if(contacts[i].number[10]==given[10])
{
printf("\n the name is: %c ",contacts[i].name[15]);
}
else printf("\n no contact found");
}
break;
default:printf("thamks for visiting");
break;
}
getch();
}



m facing lvalue error

1 Expert Answer

By:

Randy W. answered • 11/26/14

Tutor
New to Wyzant

Computer Programming Tutor (Specializing in C and C++)

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.