C++ - How to find a (variable) character in a string? -
I need to find a user-entered letter in the loop. I usually But from here, 'E' will be a letter of four variables, I do not know that How to compare the price. But I did not even create a variable to include the character How can I do this in this context? I do not have permission to use other, more effective, and more advanced methods. This is the basic course Please help! You can create a variable where you want to ask for that letter, and use that variable to compare.
string word; Four letters; Cout & lt; & Lt; "Enter a word \ n"; Cin & gt; & Gt; word; Cout & lt; & Lt; "What characters do you want to search for? \ N"; Cin & gt; & Gt; Letter; (Int i = 0; i & lt; word.length (); i ++) {if (word [i] == letter) {cout & lt; & Lt; Letter & lt; & Lt; "Is" & lt; & Lt; I + 1 & lt; & Lt; "Character of" & lt; & Lt; The word & lt; & Lt; Endl; }}
Comments
Post a Comment