Hi,
I am comfortable in c.But i find errors here in my code.I know its related to that structures cant be accessed outside main().Need s use of pointer.How to do?.Help me soon.
A revised code will be of help.
#include <stdio.h>
#include <string.h>
struct phonebook
{
char name[100];
long int phone;
}myphonebook[5];
int addtobook(void);
int printbook(void);
int i;
int main()
{
addtobook();
printbook();
return 1;
}
int addtobook()
{
for(i=0;i<5;i++)
{
printf("\n Enter name of friend:-\n");
scanf("%s",&myphonebook.name );
printf("\n Enter phone number of friend:-\n");
scanf("%ld",&myphonebook.phone );
}
return 1;
}
int printbook()
{
for(i=0;i<5;i++)
{
printf("\n Friend name %s phone number is %ld \n",myphonebook.name,myphonebook.phone);
}
return 1;
}