+ 1
String Function: Finding Length & Certain Letters
Currently I have coded out a String Array, which gets 3 Individual String from the user. Currently i'm stuck on how to find 2-3 Letters that each string inputted needs to have at the end of each one, and how to both find the end of each string, while checking if it contains the letters required. In terms of C++ i believe i would create a function (for this example named "findstring") which would contain a for loop i believe, to find the letterscin each string but i'm stuck on what that would look like My idea example is below, any suggestions are appreciated. string findString(){ for(string letters1, string letters2) //code checking each string within the array, and outputting only the string contains certains letters. }
2 odpowiedzi
+ 7
Have a look at this code. It may provide what you need to make a start
https://code.sololearn.com/clEpBDjJ60qp/?ref=app
See function FindInString
+ 2
Suppose that you have to find a substring "s" in a string "S" then how you can check if "S" end in "s"?
Well, first its clear that "s" have to be <= to "S" (in size terms). Next, you have to check any chars starting from S.length - s.length char and compare any subsequent "S" char with "s" char while mismatch is founded (resulting in "S" that not ends with "s") or "S" end reached (in this case "S" ends with "s")