How can I check if two strings are the same case insensitive
L0k3d20uz4 (1)

So I am making a program that checks to see if words are palindromes. I have a word, have reversed the word, but now I need to check if the two strings are the same not worrying about the case of the letters. I have tried using boost/algorithm/string.hpp as suggested by an answer on stackOverflow, but I'm not sure if I'm using it correctly. It does not give me any errors, but instead of displaying true or false, it displays 1 or 0. Please tell me what I'm doing wrong or if there is a better way to do this.

You are viewing a single comment. View All
Answered by Bookie0 (6407) [earned 5 cycles]
View Answer
Coder100 (18939)

case insensitivity is very very very very not straightforward

#include <ctype.h>
#include <string>

std::string to_lower(std::string s) {
  std::string out = "";
  for (char c : s) {
    s += tolower(c);

  return out;
firefish (950)

not straightforward

@Coder100 Good question... what is the opposite of straightforward? is it crookedbackward? oh wait you just say difficult don't you