Answer the question
In order to leave comments, you need to log in
Is it possible in C++ to find out the position from which a substring starts without iterating through the characters in the string?
there is a string char str[50] and a substring "tt", is it possible to somehow find out the position of a substring in a string without using the string library and character-by-character enumeration of the string str?
There is strstr () which returns a pointer to the beginning of the substring in the string str and in a separate "laboraton" case, when everything is launched in a separate program in order to only check this, the following method works for me:
char *pSubStr = strstr(str, "s");
int num = str - pSubStr;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question