Use strings, and copy into a char array. Then randomize your char array.
When the user inputs the guessed word, input it to a string. And compare the user string with the original string.
Like so:
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string example;
int string_length; //Int to hold string length so you know how much to copy.
char randomized_word[40];
memset(randomized_word, '\0', 40); /*This 'clears' everything
in the memory space of the char array. Other wise, if you copy
less characters than total array you will have a bunch of garbage */
example = "word or sentence to be randomized";
string_length = example.length(); // Returns string length and places it variable
example.copy(randomized_word,string_length); /*This is the bread and butter,
first variable in the () is the array name, then coma then the array length */
cout << randomized_word; //You still have to randomize this array, but I will leave that up to you.
But now you have a string (to compare easily, with the
== operator to what the user inputs. And an array to randomize to output.
return 0;
}
*edit*
It took a bunch of edits, but I think I finally fixed the spacing error (the forum screwed up my spacing in program and made the page really freakin wide!).