I want to replace every letter “a” in a string with the letter “e”, and return the count of the number of “a”s that we changed. My main function is supposed to be as follows but I dont know what my callimg functions signatures should be. I suppose it should be somewhat like thia bit still I dont know how to implement this function.I am a total noob. Can anybody help me??
int replaceAWithE(______string____ s) {
}
//
1 2 3 4 5 6 7 8
int main()
{
string s1 = "aardvark";
int numAChanged = replaceAWithE(s1);
cout << s1 << " num a changed: " << numAChanged << endl;}
// outputs: eerdverk num a changed: 3
// Example program
#include <iostream>
#include <string>
int replaceAWithE(std::string& s)
{
int num_changed = 0;
// ...
// for example, replace index 0 (first index) with z
s[0] = 'z';
return num_changed;
}
int main()
{
std::string s1 = "aardvark";
int numAChanged = replaceAWithE(s1);
// outputs: eerdverk num
std::cout << s1 << " num a changed: " << numAChanged << std::endl;
}
In addition, some identifiers are reserved for use by C++ implementations and shall not be used otherwise; no diagnostic is required.
- Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use. http://eel.is/c++draft/lex.name