How To Compare Two Char Arrays In Cpp Code Example


Example: c++ compare char array

// syntax #include <cstring> // this needs to be at the top of the script/code std::strcmp(<1st-char>,<2nd-char>)    // example (assuming: char_1 = 'Compare me'; char_2 = 'Compare_me') #include <cstring> if (std::strcmp(char_1,char_2) == 0) {  std::cout << "The char's that you compared match!" << std::endl;  } else {  std::cout << "The char's that you compared DON'T match" << std::endl;  }  // OUTPUT: The char's that you compared match!  /* NOTE: the following outputs of std::strcmp indicate: [less than zero] : left-hand-side appears before right-hand-side in lexicographical order [zero] : the chars are equal [greater than zero] : left-hand-side appears after right-hand-side in lexicographical order */

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools