Ok so im making a game where you enter a word and it mixes up the word and the other person has to guess what it is but im unsure of how to actually mix up the string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string word = " ";
cout << "CRYPTO GUESS\n" << endl;
cout << "Please enter your word" << endl;
cin >> word;
}
ok i got it working but i noticed when entering a word twice it puts it in the same order. I entered Traps 3 times and it comes out as srpat every time, why is that and how can i fix it?
I entered Traps 3 times and it comes out as srpat every time, why is that and how can i fix it?
Interesting. So if you run your program multiple times, it still reorders "traps" the same way? I don't think it's supposed to do this.
Anyway, the page I linked to contains an example using a custom random function. The following page shows how to do the same thing using the C++11 random library, instead of the old cstdlib:
Ah i see, i thought there was more to it than that. Ok well it works now the words are mixed up every time i run it, but now i have another problem that should be simple, i have been trying to figure it out for the last 45 minutes, i cant get the program to brak the second while loop when the right word is entered.
Well the problem is it doesnt even go into the if statement to show the "Correct!" dialog it just keeps asking to input my guess. How do i check the state of cin?
-_____- never mind it was my fault, i tried to do a do while loop and reversed it but forgot to take the ; off of the end of my while statement. thanks. now im curious, why does it work when i store the random shuffle in the random shuffle variable? is it because the random shuffle is stored in the original_word variable? so therefore when i enter the correct word it tries to compare it to the shuffled one?