Okay i am trying to make a lock
this is my code:

#include <iostream>
using namespace std;

int main ()
{
    char key [10]="abcd";
    char answer[10];
    cout<< "password:";
    cin >> answer;
    if( key == answer)
    cout << "correct";
    else
    cout << "incorrect";
    return main();
}

when ever i try to run it, it keeps saying incorrect for everything, even when i type in the correct password.

Use a std::string to store both strings, if you want to compare them with ==

Otherwise, use strcmp() declared in #include <cstring>

thank helped alot!!

if this solved your question, why don't you mark the thread as solved...

oh sorry i am new to daniweb didn't know i had to

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.