return, cout and two values
hi guys, I am the worst programmer/learner in the world and this will be obvious in a sec.
My program has two strings in a library, the second of which has three substrings.
ie:
Code:
replaceSubstrings(string inputText, string searchStr, string replaceStr)
My first question is: in my main program do I define the strings ie inputText and then use them in replaceSubstrings?
The second problem for me is when I define string searchStr, it is to replace all characters in two strings (input) and (reverseString) with *'s and !'s respectively.
Will my while loop achieve that?
Code:
// replaceStr returns *'s for all input charachters and !'s for all
// reverseString characters.
string starStr = input ;
string exclamStr = reverseString ;
int start = 0,
finish = input.size()-1;
while (start < finish)
{
exclamStr.replace(exclamStr[start],exclamStr[finish],"!");
starStr.replace(starStr[start],starStr[finish],"*");
start++;
finish--;
}
Finally, with my loops, after the while() and {} will cout print the values to screen because each time I write return ie
I recieve an error. Why is that? return is in all of the textbooks and I can't get it. I have (out of error frustration) just used cout, but I am wondering how this will affect my program.
Finally, how do I assign both exclamStr and starStr to my string replaceStr? I hope this all makes sense.
Sorry about the stupid questions, and thankyou any good person who helps me sort out my frustrations!!