Description
The purpose of this challenge is to manually manipulate character arrays. This challenge “translates human to dog.”
Requirements
- Write a program to translate any entered string into a variation of the word “Woof”
- Define 2 character arrays: char human[100], dog[100]
- Ask the user to enter a string into human. Use cin.getline(human, 100) function call to get the string from the user in main.
- Create a function void translate(char human[], char dog[]). The function will take in text via the human parameter and pass the translated text via the dog parameter – remember that arrays can be modified inside of functions and setting the characters of dog will effectively change the array passed as that parameter. Think of the human parameter as the input and the dog parameter as the output
- Translate any one-character word as “w”
- Two-character word as “wf”
- Three-character words become “wof”
- Four-character words become “woof”
- 6-character words become “woooof”
- and so on, longer words will have a ‘w’ as the first character and an ‘f’ as the last character and however many o’s to have an equivalent resulting length. Make sure your code can handle any word length up to maximum allowed by the character array.
- Maintain the case as entered by the user. If the user enters “Hello” this becomes “Wooof”
- From main–not from inside the translate() function–display the translated message
Sample Interaction / Output
Enter a string: Hey Wof (run it again) Enter a string: Hacker Woooof (run it again) Enter a string: Inception Wooooooof
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-CHAL0025b
Print Requirements