#include #include using namespace std; /* Quintuple each letter in a string * char *str : A null-terminated string * Note: str must have enough space for 5 copies of each letter! * This function should replace each letter with 5 copies of itself. * example: * char cat[16] = "cat"; * quintuple_letters(cat); * At this point, cat should contain "cccccaaaaattttt" */ void quintuple_letters(char *str){ } /* Count the occurances of a given letter in a string * const char *str : String to count letters in * char l : letter to count occurances of * example: * unsigned int result = count_letter("apple", 'p'); * result should contain the value 2 * Note: "const", because this function does not change str * If we left it off, the program would still work * But this way, you could run things like this: * cout << count_letter("book", 'o') << endl; * "book" is a const char*, so the compiler would object without const */ unsigned int count_letter(const char* str, char l){ } /* Remove the given index from a string * char *str : The string to remove the index from * size_t index : The index to remove * example: * char insect[] = "beehive"; * remove_index(insect, 1); * insect should now contain "behive" * Note: This means every character after index must shift to the left * Another note: Be careful not to duplicate the last character */ void remove_index(char *str, size_t index){ } /* Remove all occurances of a particular letter from a string * char *str : The string to remove occurances from * char letter : the letter to remove * example: * char phrase[] = "There are bees in here"; * remove_all(phrase, 'e'); * phrase should now contain "Thr ar bs in hr" * Feel free to use remove_index to do the actual removal */ void remove_all(char *str, char letter){ } int main(){ char zebra[64] = "zebra"; quintuple_letters(zebra); cout << zebra << endl; char c[128] = "chupacabra"; cout << "Chupacabra has " << count_letter(c, 'a') << " a's\n"; remove_index(c, 4); remove_index(c, 5); remove_index(c, 7); cout << "With them removed: " << c << endl; char longer[] = "Zebra and Chupacabra both have the letter a, and so do many other words, such as aadrvark, apple, cat, and kashyyyk"; remove_all(longer, 'a'); cout << longer << endl; return 0; }