Answer the question
In order to leave comments, you need to log in
How to compare 2 entered words?
I'm trying with strcmp, but it doesn't work yet.
string name1;
while (getline(cin, name1)) {
...
continue;
}
break;
}
...
string name2;
while (getline(cin, name2)) {
...
}
else if (strcmp(name1, name2) == 1)
cout << "..." << endl;
}
Answer the question
In order to leave comments, you need to log in
if (strcmp(name1, name2) == 1)
The strcmp() and strncmp() functions return an integer less than,
equal to, or greater than zero if s1 (or the first n bytes thereof)
is found, respectively, to be less than, to match, or be greater than
s2.
if (strcmp(name1.c_str(), name2.c_str()) == 0)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question