Multiple choice technology programming languages

Find a character in a string. Choose the correct one.

  1. substr

  2. find_first_of

  3. find_last_of

  4. compare

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

find_first_of() searches for the first occurrence of ANY character from the search string in the target string. For example, "hello".find_first_of("aeiou") returns 1 (position of 'e'). It's different from find() which looks for an exact substring match.