mardi 4 septembre 2018

How to check a string for repeated negative signs? for example --1

I made a function that tells me if I only have digits.

I tried doing -- ; however this just messes up my negative numbers.

bool isDigit (const std::string &str) {
  return !(str.find_first_of("!@#$^&*()_=+abcdefghifklmnopqrst"
          "uvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") == std::string::npos);
}

Aucun commentaire:

Enregistrer un commentaire