Here's the problem I Resolve:
Writing a program capable of finding a given letter within a word entered by the user. The program must identify the positions of sucessives caratère and display the character or characters found in uppercase.
example
Enter a word: extraordinary
Letter seeking: a
Result: extrAordinAry
the letter appears at positions 5 and 11.
difficulty:
Is it possible to use a loop to find the characters in the case where the letter appears more than twice?
I also find it difficult to use toupper and replace to achieve this:
Result: extrAordinAry
Thank you for your help
Here is my C + + code at this time:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word;
string letter;
int pos1, pos2;
cout << "Enter word more then ten character:\n";
cin>>word;
cout << "Letter to search: ";
cin>>letter;
string str = word;
// run through the entire string char by char once
for( int i = 0 ; i < str.length() ; i++ ){
if (str[i] == letter[0]) { // case sensitive compare
cout << "find at: " << i << endl;
str[i] &= 0xDF; // kill lower case bit
}
}
This seems cheap, but find() and rfind() do the exact same thing :)