I wanted to write a function that returns string without characters between first and last small letters 'a'. Function returns wanted output, but in main it prints out some nonsense. What could be wrong?
Thanks in advance.
there may be better ways, but one easy to follow way would be to iterate the string forward, looking for 'a', and saving the index in the string where that is.
Then do it in reverse, and save it again.
If you found an a (its ok if you found the same one twice) proceed, else return original string. Proceed, you want to pull the substrings from 0 to first a and from a to end of string, and concatenate those, return that. This will eliminate the letter a if only one a is found, is that desired? If not, you can return if the first and last a are the same index instead. It can be done more efficiently of course, this is the simple approach.