Find character in a string by it's sequence in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Find character in a string by it's sequence in c++

Could anyone tell me please that how to find a character in a string by it's sequence in c++? I know the function std::string::find, but it's for finding the location of a char, and I would like to find a char by it's location. I am using the MinGW compiler

20th Mar 2018, 1:20 PM
InfiniteFX
InfiniteFX - avatar
4 Answers
+ 4
Can you elaborate more on what you meant by finding character by its sequence here? I'm not understanding your question very well here. Btw, The std::string::find method has an overload for basic_string too, check the reference: http://en.cppreference.com/w/cpp/string/basic_string/find
20th Mar 2018, 3:57 PM
Ipang
+ 2
Thank you guys!
24th Mar 2018, 9:54 AM
InfiniteFX
InfiniteFX - avatar
+ 1
Strings have the [], like arrays do. Just do stringName[index] to get the char
20th Mar 2018, 1:46 PM
Ariela
Ariela - avatar
+ 1
std::string::at returns the char at a specified position. Square brackets can also be used to access a char at a certain position
20th Mar 2018, 6:45 PM
Kyle Bruce
Kyle Bruce - avatar