I am in my last two exercises and need some assistance starting these as I have no idea what I am doing with these...

1. Write a function replace_all(), such that a call

newString = replace_all(str, substring, newSubstring);

will return a copy of string str with each occurrence of substring replaced by newSubstring.

2. A string is said to be a palindrome if it does not change when the order of its characters is reversed. Write a function that, given a string, returns true if that string is a palindrome and returns false otherwise


Any help in getting started would be greatly appreciated.

For the first one, look at the various find() string functions, for starters.

For the second, that's been well discussed, a little search should help you find any of the several possible solutions. Best solutions do not require creating another string, but those can be the easiest.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.