Hello, I want to make an array that consist of letters that forms a word. for example
if(answer==array) {
else {

if you don't understand my question you can reply for me to clear things up.
You're trying to compare char arrays (assuming answer is also a char array). Null-terminated char arrays are commonly called strings, or C-strings (as opposed to C++'s std::string).
The comparison between cstrings is not so straightforward. You need to use the standard library function std::strcmp() or a similar std::***cmp()

strcmp() wants a cstring, but your array is not null-terminated (it's "ACE" instead of "ACE\0") so you should either add a null character at the end of your strings or use a function that lets you specify how many characters to read, like std::strncmp().
Beware that if one or both strings aren't null-terminated and you specify more characters that there are in those strings you could crash your program.

On the contrary, with std::string you CAN use == to check for equality, and is advised to use them over cstrings unless there is a reason not to.
actually, i want to make a program that looks like the game TEXT TWIST. So i want to make the letters of the word separated so that i can scramble it when the user twist the word.
i'm not sure if you can use string member function at:
Last edited on
thanks nevermore28. :D
Topic archived. No new replies allowed.