3 ms·
That's not correct. If the scanned string doesn't contain any of the search string's characters, strcspn will behave like strlen, and the snippet ends up doing
by YSFEJ4SWJUVU6 9y ago
That's not correct. If the scanned string doesn't contain any of the search string's characters, strcspn will behave like strlen, and the snippet ends up doing effectively nothing.
However, the statement is inefficient in what it does (and even then, not the most obvious way to achieve that, which your comment also highlights in a roundabout way).