How to search a string for a word/character and return its position?
If I had a string, say: "This is a string"
How would I search for a particular word or character and get it's position into an integer?
For instance, say I wanted to get the position of "a", which would be 3. Or if I wanted the position of "is" which is 2.
I know how to return the position of a character in a string like this: "a b c d e f g" using a for loop, and within the for loop, counting the number of spaces. But that is using a simple compare of the current character with the desired character.
I am confused how to do this when you have a mix of characters and words.