code.cpp 855 B

1234567891011121314151617181920212223
  1. /* Create a function that takes an array of names and returns
  2. * an array with the first letter capitalized.
  3. * Don't change the order of the original array.
  4. * Notice in the second example above, "MABELLE" is returned as "Mabelle".
  5. */
  6. // make me a lowerCASER for christmas std::string vs string&
  7. void lowerCase(std::string& strToConvert){
  8. for(unsigned int i=0;i<strToConvert.length();i++){
  9. strToConvert[i] = tolower(strToConvert[i]);
  10. }
  11. }
  12. std::vector<std::string> capMe(std::vector<std::string> arr) {
  13. std::vector<std::string> aA;
  14. for(int i = 0;i<arr.size();i++){
  15. // make all characters of each string in the array lower case
  16. lowerCase(arr[i]);
  17. // make the first character of each string in the array upper case
  18. arr[i][0] = toupper(arr[i][0]);
  19. // add each new string into a new array
  20. aA.push_back(arr[i]);
  21. }
  22. return aA;
  23. }