im trying to get the best possible way to find a member im currently using linear search (i think) witch i did something like this
void srchbook(book* books){
char tempstring[maxsize];
int i;
printf("enter the id of the book you want to find:\n");
gets(tempstring);
for(i=0;i<bookcount;i++){
if (!strcmp(tempstring,books[i].id)){
printf("the book you wanted is: %s\n",books[i].title);
printf("author: %s\n",books[i].author);
printf("year of release: %s\n",books[i].year);
printf("pages: %s\n",books[i].pages);
printf("Genre: %s\n",books[i].subject);
break;
}
}
if(i >= bookcount){
printf("no result :(\n");
}
printf("issue another command\n");
pick(books);
}
is there anyway i can make it more efficient? i was thinking of binary search but im not really sure it would be more efficient. also if i did the search recursively would it made any impact?