Hi, I wanted to try to write a game in which I had to guess the hidden word, the question: how? Here is an example code:

#include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main() { string s; cin >> s; int a = s.size(); return 0; } 

Well, and then I do not know)

    2 answers 2

    The answer to your question is in English SO:

     #include <algorithm> #include <iostream> #include <string> using namespace std; int main(){ string str; cout << "Please enter a word: "; //ask for input cin >> str; random_shuffle(str.begin(), str.end()); cout << str << endl; } 

      Suppose you can make a text file with words (in each line by the word), read line by line into an array of words, then randomly select one of them, and randomly mix letters in it, and then compare the respondent's answer with a standard.

      • So I want to know how to shuffle the word - Denis SafonoV
      • Then a kind person above answered your question perfectly) - badmoonrising