0
failed build for my project
A message of (control may reach end of non-void function) why? here Is my code : int search(book x[], int size , string name){ for(int=0 ; i<size ; i++) if(name.compare(x[i].nameOfbook)==0) return i; }
1 Odpowiedź
+ 2
What if the if block never true.. For that You shloud add return statement as last statement
return -1; //for search unsuccessful....
So correct code:
int search(book x[], int size , string name){
for(int=0 ; i<size ; i++)
if(name.compare(x[i].nameOfbook)==0)
return i;
return -1;
}