0
How can I write any letter and let c++ to display random words for me ?
Letter random word
3 odpowiedzi
+ 2
You could use a char array. But I highly discourage you from doing so.
Because you'll have to work with char** type and no one likes double pointers.
I recommend a vector of strings instead.
https://en.cppreference.com/w/cpp/container/vector
https://en.cppreference.com/w/cpp/string/basic_string
Simply do something like
std::vector<std::string> words = { "word1", "word2", "word3", etc };
I'll let you do the rest, if you need more help, feel free to ask.
I do expect to see code before I can help with more specific problems though.
+ 1
First you'll need random words to begin with.
With a little bit of googling you can find a large txt file with thousands of dictionary words.
Then, simply load the entire file into a data structure.
I recommend the Trie data structure as it is designed for fast lookup of strings given the first few characters.
https://en.m.wikipedia.org/wiki/Trie
Or, you could just hardcode a small array with strings.
+ 1
Thanks. But can I do this using "Char" array ? If yes please show me a code example