Help.

When input is obtained - such as a book's title - then convert it to say lowercase and store. Then when the name is entered for search also convert to lowercase before the comparison. Or store as entered and convert the stored value and the entered value to lowercase and then compare.

Or you can use the non-standard stricmp() [_stricmp() for VS] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l?view=msvc-170

you will need to tokenize the input if you want to match gatsby great ..
what you do is split the input into strings, the do a search of the string (find()) against each book title in your library. the ones that matched, you will check the next word against those.. until you have nothing left (no match) or checked all the words. This assumes you already converted everything to the same case.

if you want partial results, you can do something, where it matches 50% for example (here, everything with great would pop up as a 50% match for example). whatever your requirement is there.
finally, this is why you index searches. searching lots of titles for lots of words is expensive, so if you index the keywords to reduce the # of things to look at, it is orders of magnitude faster.
Last edited on
Are you writing C or C++?
Pick one. When possible avoid mixing them.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.