Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct address{
- int house;
- char area[10];
- };
- struct add_cont{
- char first_name[20];
- char last_name[20];
- long long cell;
- struct address addr;
- };
- int new_contact();
- int search_old();
- int main()
- {
- int entry, test;
- char choice[100];
- printf("Welcome to Proloy Phone Book\n\n");
- for(;;){
- printf("\nFor New Contact,\nPress 1\n");
- printf("\nFor Searching Old Contact,\nPress 2\n");
- scanf("%d", &entry);
- switch(entry){
- case 1:
- new_contact();
- //printf("Enter a new number:\n");
- //scanf("%d", &test);
- break;
- case 2:
- search_old();
- //printf("Enter a new code:\n");
- //scanf("%d", &test);
- break;
- default:
- printf("Invalid Key word\nTry again :)\n");
- break;
- }
- printf("\nDo you want to continue?\nPress enter to your choice; 'Yes' or 'No'\n");
- scanf("%s", choice);
- if(choice[0]=='Y' || choice[0]=='y')
- continue;
- else if(choice[0]=='N' || choice[0]=='n'){
- printf("Thank you for using our phone book :)\n");
- break;
- }
- else{
- printf("Invalid Key word :/\n");
- printf("\nDo you want to continue?\nPress enter to your choice; 'Yes' or 'No'\n");
- scanf("%s", choice);
- }
- }
- return 0;
- }
- int new_contact()
- {
- struct add_cont in1[10];
- int i=0, n, p;
- char choice[4];
- i=0;
- for(;;){
- i++;
- printf("Enter your first name :");
- scanf("%s", in1[i].first_name);
- printf("Enter your last name :");
- scanf("%s", in1[i].last_name);
- printf("Enter your cell number :");
- scanf("%lld", &in1[i].cell);
- printf("Enter your address :");
- scanf("%lld", &in1[i].addr.house);
- scanf("%s", in1[i].addr.area);
- // i++;
- printf("\nDo you want to save another contact?\nIf you want, enter 'yes'\nIf you do not want, enter 'No'\n");
- scanf("%s", choice);
- if(choice[0]=='y')
- continue;
- else
- //return i;
- break;
- }
- printf("Enter the key word\t:");
- scanf("%d", &p);
- if(p>i)
- printf("Invalid :/\n");
- else
- printf("\nName\t: %s %s\nCell No\t: %011lld\nAddress\t: %d,%s\n", in1[p].first_name,in1[p].last_name,in1[p].cell,in1[p].addr.house,in1[p].addr.area);
- }
- int search_old()
- {
- // int n;
- // n=new_contact(n);
- // printf("%d\n", n);
- // if(i==0)
- //
- printf("Vuila gesi :3\n");
- // return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement