Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void query()
- {
- int i,j,k,l;
- char swap_[20];
- for(i=0; i<counter; i++)
- {
- lowercase(person[i].fname);
- lowercase(person[i].lname);
- }
- for (i=0 ; i < counter; i++)
- {
- for (j=0; j < counter-1; j++)
- {
- if (strcmp(person[j].lname,person[j+1].lname)>0)
- {
- strcpy(swap_,person[j].lname);
- strcpy(person[j].lname,person[j+1].lname);
- strcpy(person[j+1].lname,swap_);
- strcpy(swap_,person[j].fname);
- strcpy(person[j].fname,person[j+1].fname);
- strcpy(person[j+1].fname,swap_);
- strcpy(swap_,person[j].address);
- strcpy(person[j].address,person[j+1].address);
- strcpy(person[j+1].address,swap_);
- strcpy(swap_,person[j].city);
- strcpy(person[j].city,person[j+1].city);
- strcpy(person[j+1].city,swap_);
- strcpy(swap_,person[j].number);
- strcpy(person[j].number,person[j+1].number);
- strcpy(person[j+1].number,swap_);
- }
- else if(strcmp(person[j].lname,person[j+1].lname)==0)
- {
- if (strcmp(person[j].fname,person[j+1].fname)>0)
- {
- strcpy(swap_,person[j].lname);
- strcpy(person[j].lname,person[j+1].lname);
- strcpy(person[j+1].lname,swap_);
- strcpy(swap_,person[j].fname);
- strcpy(person[j].fname,person[j+1].fname);
- strcpy(person[j+1].fname,swap_);
- strcpy(swap_,person[j].address);
- strcpy(person[j].address,person[j+1].address);
- strcpy(person[j+1].address,swap_);
- strcpy(swap_,person[j].city);
- strcpy(person[j].city,person[j+1].city);
- strcpy(person[j+1].city,swap_);
- strcpy(swap_,person[j].number);
- strcpy(person[j].number,person[j+1].number);
- strcpy(person[j+1].number,swap_);
- }
- else if(strcmp(person[j].fname,person[j+1].fname)==0)
- {
- if(strcmp(person[j].number,person[j+1].number)>0)
- {
- strcpy(swap_,person[j].lname);
- strcpy(person[j].lname,person[j+1].lname);
- strcpy(person[j+1].lname,swap_);
- strcpy(swap_,person[j].fname);
- strcpy(person[j].fname,person[j+1].fname);
- strcpy(person[j+1].fname,swap_);
- strcpy(swap_,person[j].address);
- strcpy(person[j].address,person[j+1].address);
- strcpy(person[j+1].address,swap_);
- strcpy(swap_,person[j].city);
- strcpy(person[j].city,person[j+1].city);
- strcpy(person[j+1].city,swap_);
- strcpy(swap_,person[j].number);
- strcpy(person[j].number,person[j+1].number);
- strcpy(person[j+1].number,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