• If loop and while loop
    2 replies, posted
-snip- can use "strcmp" :ohdear:
There is no such thing as an if loop... Anyway, you can use std::strcmp (#include<cstring>) to compare strings represented by null-terminated character arrays: [cpp] if(strcmp(hello, "hello") != 0) { //hello is not "hello" } [/cpp] Keep in mind that hello[5] can't actually fit "hello", though, because you need room for the null terminator. Also, use cin.getline instead of >> for strings: [cpp] char hello[6]; cin.getline(hello, 6); [/cpp] That way you don't get buffer overflows.
Please delete this thread.
Sorry, you need to Log In to post a reply to this thread.