code.cpp 269 B

123456789
  1. /* Create a function that returns true if a string contains any spaces.
  2. */
  3. bool hasSpaces(std::string str) {
  4. // loop through each character in string, if its a space return true
  5. for (int i = 0;i<str.size();i++){
  6. if (' '==str[i]){return true;}
  7. }
  8. return false;
  9. }