Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print()
- {
- int i,j,k,l;
- phonebook swap_;
- for (i=0 ; i < counter; i++)
- {
- for (j=0; j < counter-1; j++)
- {
- if (strcmpi(person[j].lname,person[j+1].lname)>0)
- {
- swap_=person[j];
- person[j]=person[j+1];
- person[j+1]=swap_;
- }
- else if(strcmpi(person[j].lname,person[j+1].lname)==0)
- {
- if (strcmpi(person[j].fname,person[j+1].fname)>0)
- {
- swap_=person[j];
- person[j]=person[j+1];
- person[j+1]=swap_;
- }
- else if(strcmpi(person[j].fname,person[j+1].fname)==0)
- {
- if(strcmp(person[j].number,person[j+1].number)>0)
- {
- swap_=person[j];
- person[j]=person[j+1];
- person[j+1]=swap_;
- }
- }
- }
- else
- continue;
- }
- }
- system("cls");
- for (i=0 ; i <counter; i++)
- printf("%d)\nfirst name: %s\nlast name: %s\nAddress: %s\nCity: %s\nNumber: %s\n",i+1,person[i].fname,person[i].lname,person[i].address,person[i].city,person[i].number);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement