Error in a selection sort c++ : I have this action for order array in sort selection method, but this code dont order my array correctly

    void selectionsort(int* b,int size)
    {
     int i, k,menor,posmenor;
     for(i=0;i<size-1;i++)
     {
      posmenor=i;
      menor=b[i];
      for(k=i+1;k<size;k++)
      {
       if(b[k]<menor)
       {
        menor=b[k];
        posmenor=k;
       }
      }
      b[posmenor]=b[i];
      b[i]=menor;                    
     }
    }

I Dont found the error. 

Im newbie in c++

Thanks for help.