Hello! I have been struggling with this program, the prompt and the code I have created thus far is below:
Create a program that includes a function called spaced that takes a string and returns a string with spaces beteen each character (including spaces). For example, given “hello” as the input, the function should return “h e l l o ”, which is the spaced string of “hello”.
The main function should prompt the user to input a string until the user types “Q” For each string input call the function with the string and display the result. Note that the user input string may contain white spaces.
I would include the header file "<cctype>" and in your function "Spaced" make use if the function "isspace" in the for loop. I am thing of something like:
1 2 3
for(...)
if (!isspace(userString[i]))
spacedString+=userString[i];
I will have to go test this, but that is my thought for now. You could change this to not use the built in functions in which case it would follow thae same type of concept.
Hope that helps,
Andy
P.S. As I worked on the program I ended up using the same concept as FurryGuy did in his for loop except I used the for loop that you started with.