After going through a bunch of threads, I know that I need to use regex.h for using regular expressions in C & C++.
But I was wondering, is there an easier way to search for occurrence of “/” or “\” in a string.
// I have a strstr statement like this -
str = strstr(s, "/");
I was wondering if it is possible to change it so that I can search for the first occurrence of a or
/\ in a single call to strstr.
Try strcspn:
Example:
Edit:
strpbrkdoes the same thing asfindanyabove. Didn’t see that function:Output (of both):