I am trying to implement the strcmp function to be able to sort a list of businesses, but i keep getting an error on the line where it's supposed to be comparing them.
Code:void business::Sort(vector<string>& list,string strcmp(const char *s1,const char *s2)) { if(list.size()==1){return;} else { for(int x=0;x<list.size();x++) { for(int y=0;y<list.size()-1;y++) { double b=(strcmp(list[y],list[y+1])); // error always happens here no matter how i try and change it if(b==-1) {swap(list[y],list[y+1]);} } } } } int business::strcmp(const char *s1, const char *s2) { while (*s1==*s2) { if(*s1=='\0') return(0); s1++; s2++; } return(*s1-*s2); }



LinkBack URL
About LinkBacks



