strchr method

int strchr(
  1. String str,
  2. String c
)

Finds the first occurrence of the character c (given as a String) in the string str.

Returns the index of the character, or -1 if the character is not found. (Deviation from C: Returns an integer index instead of a pointer).

Implementation

int strchr(String str, String c) {
  if (c.isEmpty) return -1;
  return str.indexOf(c[0]);
}