sorting array of struct by id
===

I  take array of record as case study in my Graduation Project and I **write** this code in this code I made an array of struct and enter the id of the structs in an array 
of int to make the sorting easier but when it run it stuck
    
     #include<iostream.h>
       struct book{
           char Bname [8],Bsubject[8];
            int copyies,Bid,Bfound;
           }a[100];
     void Ider(book a[],int r[],int index){
        for(int i=0;i<index;i++)
            r[i]=a[i].Bid;
           }
     void swap(int &a,int &b){
          int c=a;
              a=b;
              b=c;}
     void Bublesort(int a[],int n){
          for(int i=0;i<n;i++)
              if(a[i]>a[i+1])
                swap(a[i+1],a[i]);
                
                               }
     int bsearch(int b[],int key,int first,int last){
        int  midel=(first+last)/2;
        for(int i=0;i<last;i++){
         if(b[midel]==key)
         return midel;
         else 
         if(b[midel]>key)
         return bsearch(b,key,first,midel-1);
         else 
         if(b[midel]<key)
         return bsearch(b,key,midel+1,last);
         }
      }
                   
               
         int main(){
         
         int r,i, index=0,m[100];
         char ch;
         do{
         cout<<"Enter your"<<index+1<<" Book id"<<"    ";
         cout<<endl;
         cin>>a[index].Bid;
         cout<<"Enter your"<<index+1<<" Book name"<<"    ";
         cout<<endl;
         cin>>a[index].Bname;
         cout<<"Enter your"<<index+1<<" Book subject"<<"    ";
         cout<<endl;
         cin>>a[index].Bsubject;
         index++;
         a[index].Bfound++;
         a[index].copyies++;
         if(index==99)
         break;
        
          
         quite : cout<<"Do you want to continue";
         cin>>ch;
                }while(ch=='y');
                Ider(a,m,index);
                Bublesort(m,index);
         char p;
                do{
                cout<<"Do you want to search?"<<endl;
                cin>>p;
                cout<<"enter your id";
                cin>>i; 
                r=bsearch(m,i,0,index);
                cout<<a[r].Bfound<<"          ";
                               
                }while(ch=='y');
               system("pause");
               return 0;}
  *   when reatch bublesort it stuk  and  didn't give any output but why?
 