How to find index of string in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to find index of string in c++

26th Feb 2020, 9:55 AM
Rrrrrr
Rrrrrr - avatar
2 Answers
+ 3
Adding to above: size_t index= str.find(str1); It return index of first occurrence of str1 string from owl str string... Ex: str="ab cdef" ; str1="ab" ; size_t index= str.find(str1); index=0; //at 0 position...
26th Feb 2020, 10:49 AM
Jayakrishna 🇮🇳
+ 2
I believe you can access the characters of the string like an array Such as String s = "Hello"; char c = str[3];
26th Feb 2020, 10:04 AM
Rodrigo Sanchez
Rodrigo Sanchez - avatar