| bob39rocks (6) | |
|
Hello, In my little experiment i am trying to get the compiler to recognize 1 word with 2 parts from a list of names. for example: if the user wanted to choose "candy bar", from a list of items which include: "candy bar", "cat", "dog" my current code can recognize words without a space like cat and dog. But how can i recognize candy bar? I tried using getline but its of no use. Any help is appretiated. Thanks. | |
|
|
|
| Smac89 (195) | |
|
getline(cin, str) or cin >> str or stringstream mystr(str) E: Just thought about it again. So you have a library of words and you are trying to get as many matches to any input the user enters. So say the user enters: rain, bow And your library contains the words: string lib [] = {"cat", "dog", "rainbow", "rain", "bow"};, it should match rain, bow, and rainbow string temp; string word1; string word2; for(...) { if lib[j] == word1 || lib[j] == word2 ... } temp = word1 + " " + word2; for(...) { if lib[j] == temp ... } Something like that? | |
|
Last edited on
|
|
| cire (2347) | |||
| |||
|
|
|||