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
?
More Related Contents:
- The array index doesnt show the character [closed]
- How to convert a std::string to const char* or char*
- Is a string literal in С++ created in static memory?
- Why is conversion from string constant to ‘char*’ valid in C but invalid in C++
- std::string to char*
- Why does streaming a char pointer to cout not print an address?
- C++ Compare char array with string
- Conversion from string literal to char* is deprecated
- Deprecated conversion from string literal to ‘char*’
- cannot convert ‘std::basic_string’ to ‘const char*’ for argument ‘1’ to ‘int system(const char*)’
- How to convert a char array to a string?
- How can I create a string from a single character?
- What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?
- Assign a string literal to a char* [duplicate]
- cannot convert ‘std::string’ to ‘char**’ for argument ‘1’ to ‘__ssize_t getline(char**, size_t*, FILE*)’
- Why when i add number to string it shows random text in c++?
- Converting std::__cxx11::string to std::string
- Will std::string always be null-terminated in C++11?
- What’s the rationale for null terminated strings?
- stringstream, string, and char* conversion confusion
- Fast String Hashing Algorithm with low collision rates with 32 bit integer [closed]
- std::strings’s capacity(), reserve() & resize() functions
- splitting a string into an array in C++ without using vector
- Case insensitive string comparison C++ [duplicate]
- How do I print the full value of a long string in gdb?
- What is the correct way to compare char ignoring case?
- Conversion of Char to Binary in C
- Check if one string is a prefix of another
- Function stoi not declared
- “cout” and “char address” [duplicate]