Random Chars/Words

Okay, I'm pretty sure this subject has been talked over before, but can anyone tell me how to make a random word generator. For example:

string Word%rand(pie, cake, crusts);

I don't know, that was just a guess. Please help if you can, thanks.
1
2
string list[] = {"pie", "cake", "crusts"};
cout << list[ rand()%3 ];
Thank you <3
Okay, so how do I do this now:

1
2
string list[] = {"pie", "cake", "crusts"};
cout << list[ rand()%3 ];


1
2
3
4
if (list[] == "cake")
{
//stuff
}


Because when I do this it comes back with this error:

expected primary-expression before ']' token

and without the [] I get:

comparison between distinct pointer types `std::string*' and `const char*' lacks a cast

and I don't know what they mean >_< any ideas?
Nevermind, did it a different way:
1
2
3
4
list2 = list[rand ()%3];
if (list2 == "cake")
{
}
Topic archived. No new replies allowed.