Perex19 Perex19 - 1 year ago 128
C Question

strcmp or string::compare?

I want to compare two strings. Is it possible with

? (I tried and it does not seem to work). Is
a solution?

Other than this, is there a way to compare a
to a

Thanks for the early comments. I was coding in C++ and yes it was
like some of you mentioned.
I didn't post the code because I wanted to learn the general knowledge and it is a pretty long code, so it was irrelevant for the question.

I think I learned the difference between C++ and C, thanks for pointing that out. And I will try to use overloaded operators now. And by the way
worked too.

Answer Source

For C++, use std::string and compare using string::compare.

For C use strcmp. If your (i meant your programs) strings (for some weird reason) aren't nul terminated, use strncmp instead.

But why would someone not use something as simple as == for std::string ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download